-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·76 lines (58 loc) · 1.45 KB
/
setup.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
# Base script taken from this blogpost: https://dev.to/writingcode/how-i-manage-my-dotfiles-using-gnu-stow-4l59
old_theme="$1"
new_theme="$2"
# make sure we have pulled in and updated any submodules
git submodule init
git submodule update
destow() {
usr=$1
app=$2
stow -v -D -t $usr $app
}
# run the stow command for the passed in directory $2 in location $1
stowit() {
usr=$1
app=$2
stow -v -R --no-folding -t $usr $app
}
echo ""
echo "Removing current theme dotfiles"
cd $(dirname "$(realpath $0)")/$old_theme
source config.sh
# install apps available to local users and root
for app in ${base[@]}; do
destow "${HOME}" "$app"
done
# install only user space folders
for app in ${useronly[@]}; do
if [[ ! "$(whoami)" = "root" ]]; then
destow "${HOME}" "$app"
fi
done
echo ""
echo "Stowing apps for user: $(whoami)"
cd ../$old_theme
source config.sh
# install apps available to local users and root
for app in ${base[@]}; do
stowit "${HOME}" "$app"
done
# install only user space folders
for app in ${useronly[@]}; do
if [[ ! "$(whoami)" = "root" ]]; then
stowit "${HOME}" "$app"
fi
done
echo ""
echo "Executing theme commands..."
for cmd in "${commands[@]}"; do
$(eval $cmd)
done
echo ""
if [[ "${base[@]}" =~ "zsh" || "${useronly[@]}" =~ "zsh" ]]; then
echo "Remember to set \$ZDOTDIR"
echo "(e.g. sudo echo 'export ZDOTDIR=~/.config/zsh' >> /etc/zsh/zshenv)"
fi
echo ""
echo "##### ALL DONE #####"