aboutsummaryrefslogtreecommitdiff
path: root/scripts/bootstrap.sh
blob: 162c8540980ae7ee61927ade9a67c7203ae34fe0 (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
36
37
38
#!/usr/bin/env bash

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

mkdir -p "$HOME/.config"

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

        rm -v -rf $HOME/$var
        ln -v -s $dotfiles_dir/$var $HOME/$var
    done
}

link_all () {
    remove_and_link .ctags.d .mutt bin .aliases .macos \
        .tmux.conf .urlview .zshrc \
        .vimrc .vim .path .functions .emacs.d .gitconfig \
        .config/i3 .config/polybar .xinitrc .pam_environment \
        .zprofile .newsboat .ledgerrc .nnnrc .alacritty.yml .fzfrc .zplugrc \
        .env .zrc .config/kitty .wezterm.lua .config/mpv
}

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

    remove_and_link $@
}

main "$@"