-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotfiles.sh
executable file
·54 lines (47 loc) · 1.4 KB
/
dotfiles.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
# delete existing dotifles and create dotfiles symlinks with Stow
install_dotfiles() {
local PACKAGES=$@
for PACKAGE in $PACKAGES; do
CONFLICTS=$(stow -nv -t $HOME $PACKAGE 2>&1 | awk '/\* existing target is/ {print $NF}')
if [[ ! -z ${CONFLICTS} ]]; then
for FILENAME in ${CONFLICTS[@]}; do
if [[ -f $HOME/$FILENAME || -L $HOME/$FILENAME ]]; then
echo "DELETE: $FILENAME"
rm -f "$HOME/$FILENAME"
fi
done
fi
stow -v -D -t $HOME $PACKAGE
stow -v -t $HOME $PACKAGE
done
}
# delete dotfiles symlinks created by Stow
clean_dotifles() {
local PACKAGES=$@
for PACKAGE in $PACKAGES; do
stow -v -D -t $HOME $PACKAGE
done
}
# do not run as root or with sudo
if [[ $EUID -eq 0 ]]; then
echo "Error: you must not be root to run this script."
exit 1
fi
# environment definition
PACKAGES=(
alacritty bash brave obsproject fontconfig git gtk kitty mako nvim
ssh sway tfswitch tmux waybar zsh flameshot zoom fzf vscode swaylock
chromium electron kanshi paru wob swappy backgrounds slack fuzzel spotify
pcmanfm tgswitch audacity bat starship
)
case "$1" in
install)
install_dotfiles ${PACKAGES[@]}
;;
clean)
clean_dotifles ${PACKAGES[@]}
;;
*)
echo "Usage: $0 [install|clean]"
esac