diff options
author | Blaise Thompson <blaise@untzag.com> | 2018-07-02 21:18:45 -0500 |
---|---|---|
committer | Blaise Thompson <blaise@untzag.com> | 2018-07-02 21:18:45 -0500 |
commit | 7bcb0b78ce9e70b5e09ed84677742357ffdd3709 (patch) | |
tree | e33afbc154c0c302b78c7888d9e019b77df6340a /link.sh | |
parent | 4fda7b1b6eb947fbf0c9d8e2fe654d4db039401b (diff) |
2018-07-02 21:18
Diffstat (limited to 'link.sh')
-rwxr-xr-x | link.sh | 54 |
1 files changed, 34 insertions, 20 deletions
@@ -1,25 +1,39 @@ -!/bin/bash +#!/bin/bash -# create dotfiles_old in homedir -olddir=~/dotfiles_old -mkdir -p $olddir +# 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") -# change to the dotfiles directory -dir=~/dotfiles/dotfiles -cd $dir +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 +} -# move current files and link contained files -files=$(ls $dir) -for f in $files; do - name=${f//+//} - echo $name - mv ~/.$name ~/dotfiles_old/ - ln -s $dir/$f ~/.$name -done +# bash +link-file $HERE/bash/bashrc.sync ~/.bashrc.sync + +# 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 -ln -sf ~/dotfiles/i3/config ~/.config/i3/config -ln -sf ~/dotfiles/i3/lock.sh ~/.config/i3/lock.sh -ln -sf ~/dotfiles/i3/toggle_mouse.sh ~/.config/i3/toggle_mouse.sh -mkdir ~/.config/i3status -ln -sf ~/dotfiles/i3/i3status+config ~/.config/i3status/config +link-file $HERE/i3/config ~/.config/i3/config + +# ssh +link-file $HERE/ssh/config ~/.ssh/config |