aboutsummaryrefslogtreecommitdiff
path: root/bootstrap.sh
blob: 8248252cf3879a3bc41159388f0b8e427e5893f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash

dotfiles_dir=$(cd -- "$(dirname ${BASH_SOURCE})" > /dev/null 2>&1; pwd -P)

remove_and_link () {
    for var in $@
    do
        if [ -L $HOME/$var ] && [ -e $HOME/$var ] && \
            [ "$(readlink -- $HOME/$var)" = "$dotfiles_dir/$var" ]; then
            continue
        fi

        rm -rf $HOME/$var
        ln -s $dotfiles_dir/$var $HOME/$var
        echo "Linked: $HOME/$var -> $dotfiles_dir/$var"
    done
}

link_all () {
    remove_and_link .ctags.d .mutt bin .aliases .macos \
        .mbsyncrc .msmtprc  .tmux.conf .urlview .zshrc \
        .vimrc .vim .path .functions .emacs.d .gitignore
}

main () {
    if [ $# -eq 0 ] || [ $1 -eq 'all' ]; then
        link_all
        return
    fi

    remove_and_link $@
}

main $@