#!/bin/bash # Absolute path to this script, e.g. /home/user/bin/foo.sh SCRIPT=$(readlink -f "$0") # Absolute path this script is in, thus /home/user/bin HERE=$(dirname "$SCRIPT") function link-file(){ src=$1 dst=$2 # if there is a normal file there, remove it if [ -f "src" ] then rm $src fi # ensure destination directory exists mkdir -p $(dirname "$dst") # link ln -sf "$1" "$2" echo $dst "linked to" $src } # bash link-file $HERE/bash/bashrc.sync ~/.bashrc.sync # direnv link-file $HERE/direnv/direnvrc ~/.config/direnv/direnvrc # dunst link-file $HERE/dunst/dunstrc ~/.config/dunst/dunstrc # emacs link-file $HERE/emacs/init.el ~/.emacs.d/init.el # git link-file $HERE/git/gitconfig ~/.gitconfig # i3 link-file $HERE/i3/config ~/.config/i3/config # ssh link-file $HERE/ssh/config ~/.ssh/config # x link-file $HERE/x/Xresources ~/.Xresources