/ make-symlinks
make-symlinks
1 #!/bin/sh 2 3 set -eu 4 5 die() { 6 echo "$@" 1>&2 7 exit 1 8 } 9 10 abspath() { 11 (cd "$1" && pwd) 12 } 13 14 src() { 15 dirname="$1" 16 file="$2" 17 hosted="$dirname/host-$(hostname)/$file" 18 plain="$dirname/$file" 19 if [ -e "$hosted" ]; then 20 echo "$hosted" 21 elif [ -e "$plain" ]; then 22 echo "$plain" 23 else 24 die "$file does not exist" 25 fi 26 } 27 28 dirname="$(abspath "$(dirname "$0")")" 29 echo "$dirname" 30 31 files=" 32 abcde.conf 33 bash_profile 34 bashrc 35 emacs.d 36 git-global-ignore 37 mailcap 38 profile 39 screenrc 40 signature 41 tmux.conf 42 vimrc 43 xsessionrc 44 ssh/config 45 ssh/config-pers 46 config/starship/config.toml 47 config/vmadm/config.yaml 48 " 49 50 install -d "$HOME/.config" 51 for x in $files; do 52 src "$dirname" "$x" 53 done 54 55 for x in $files; do 56 y="$(src "$dirname" "$x")" 57 d="$(dirname "$x")" 58 if [ ! -e "$HOME/.$d" ]; then 59 mkdir -p "$HOME/.$d" 60 fi 61 ln -sf "$y" "$HOME/.$x" 62 done