dotfiles

configuration files
git clone https://pi.duncano.de/git/dotfiles.git

install.sh (2921B)


      1 #!/bin/sh
      2 
      3 msg() { t=$1; shift; printf '%s: %s\n' "$t" "$@"; }
      4 
      5 _ln_home() {
      6 	[ -z "$2" ] && tgt="$HOME/$1" || tgt="$HOME/$2"
      7 	src="$PWD/$1"
      8 	[ -e "$tgt.bak" ] && rm "$tgt.bak"
      9 	[ -e "$tgt" ] && mv "$tgt" "$tgt.bak"
     10 	ln -sf "$src" "$tgt"
     11 }
     12 _mkdir() {
     13 	for x; do
     14 		mkdir -p "$HOME/$x"
     15 	done
     16 }
     17 
     18 _vim() {
     19 	[ -n "$(command -v vim 2>/dev/null)" ] || return
     20 	msg "INSTALL" "vim config"
     21 	_ln_home "vimrc" ".vimrc"
     22 	_ln_home "vim" ".vim"
     23 	# install plugins
     24 	# vim +PlugInstall +qall
     25 }
     26 _xorg() {
     27 	[ -n "$(command -v Xorg 2>/dev/null)" ] || return
     28 	msg "INSTALL" "xorg config"
     29 	_ln_home "xinitrc" ".xinitrc"
     30 	_ln_home "Xresources" ".Xresources"
     31 	_ln_home "us-intl-german.xmodmap" ".us-intl-german.xmodmap"
     32 }
     33 _fonts() {
     34 	[ -n "$(command -v Xorg 2>/dev/null)" ] || return
     35 	msg "INSTALL" "fontconfig config"
     36 	_mkdir ".config/fontconfig"
     37 	_ln_home "fonts.conf" ".config/fontconfig/fonts.conf"
     38 }
     39 _mksh() {
     40 	[ -n "$(command -v mksh 2>/dev/null)" ] || return
     41 	msg "INSTALL" "mksh config"
     42 	_ln_home "mkshrc" ".mkshrc"
     43 }
     44 _ksh() {
     45 	[ -n "$(command -v ksh 2>/dev/null)" ] || return
     46 	msg "INSTALL" "ksh config"
     47 	_ln_home "kshrc" ".kshrc"
     48 }
     49 _yash() {
     50 	[ -n "$(command -v yash 2>/dev/null)" ] || return
     51 	msg "INSTALL" "yash config"
     52 	_ln_home "yashrc" ".yashrc"
     53 }
     54 _shell() {
     55 	msg "INSTALL" "shell config"
     56 	_ln_home "profile" ".profile"
     57 	_ln_home "inputrc" ".inputrc"
     58 	_ln_home "aliases" ".aliases"
     59 }
     60 _git() {
     61 	[ -n "$(command -v git 2>/dev/null)" ] || return
     62 	msg "INSTALL" "git config"
     63 	_ln_home "gitconfig" ".gitconfig"
     64 	_ln_home "gitignore_global" ".gitignore_global"
     65 }
     66 _void() {
     67 	[ -n "$(command -v xbps-install 2>/dev/null)" ] || return
     68 	msg "INSTALL" "void config"
     69 	_ln_home "xbps-src.conf" ".xbps-src.conf"
     70 }
     71 _ssh() {
     72 	[ -n "$(command -v ssh 2>/dev/null)" ] || return
     73 	msg "INSTALL" "ssh config"
     74 	mkdir -p "$HOME/.ssh"
     75 	_ln_home "ssh/config" ".ssh/config"
     76 }
     77 _bin() {
     78 	msg "INSTALL" "user bin directory"
     79 	_ln_home "bin"
     80 }
     81 _runit() {
     82 	[ -n "$(command -v runsvdir 2>/dev/null)" ] || return
     83 	msg "INSTALL" "runit user services"
     84 	_ln_home "sv"
     85 	_ln_home "service"
     86 	_ln_home "service.x"
     87 }
     88 _gtk() {
     89 	[ -n "$(command -v Xorg 2>/dev/null)" ] || return
     90 	msg "INSTALL" "gtk config"
     91 	_ln_home "gtkrc-2.0" ".gtkrc-2.0"
     92 	_ln_home "gtk-3.0" ".config/gtk-3.0"
     93 }
     94 _firefox() {
     95 	[ -n "$(command -v firefox 2>/dev/null)" ] || return
     96 	printf "INSTALL: firefox user.js for profile: "
     97 	for p in ~/.mozilla/firefox/*/; do
     98 		p="${p%/*}"; p="${p##*/}"
     99 		case "$p" in *backup*|*crashrecovery*|"") continue ;; esac
    100 		printf " %s\n" "'${p}'"
    101 		_ln_home "user.js" ".mozilla/firefox/$p/user.js"
    102 		mkdir -p "$HOME/.mozilla/firefox/$p/chrome"
    103 		_ln_home "userChrome.css" ".mozilla/firefox/$p/chrome/userChrome.css"
    104 	done
    105 }
    106 _tmux() {
    107 	[ -n "$(command -v tmux 2>/dev/null)" ] || return
    108 	msg "INSTALL" "tmux config"
    109 	_ln_home "tmux.conf" ".tmux.conf"
    110 }
    111 
    112 : ${PWD:=$(pwd)}
    113 : ${HOME:=~}
    114 
    115 _mksh
    116 _ksh
    117 _yash
    118 _shell
    119 _bin
    120 _runit
    121 _git
    122 _xorg
    123 _fonts
    124 _vim
    125 _void
    126 _ssh
    127 _gtk
    128 _firefox
    129 _tmux