aboutsummaryrefslogtreecommitdiff
path: root/scripts/bootstrap.sh
blob: ada87ad4f9f67b04c3971849162845268533609b (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
39
40
#!/usr/bin/env bash

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

mkdir -p "$HOME/.config" "$HOME/.local/share"

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 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 .config/kitty .wezterm.lua .config/mpv \
        .config/sway .config/swaylock .config/zathura .tigrc .config/foot \
        .config/fish .arch.aliases .bashrc
}

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

    remove_and_link $@
}

main "$@"