-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·54 lines (48 loc) · 1.25 KB
/
install
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
#!/usr/bin/env bash
JUST_CORE=false
for arg in "$@"; do
if [[ "$arg" == "--core" ]]; then
JUST_CORE=true
break
fi
done
if [[ -z $DOTFILES ]]; then
DOTFILES="$HOME/.dotfiles"
fi
# Using find to get a list of directories in DOTFILES, excluding hidden ones
STOW_FOLDERS=$(find "$DOTFILES" -mindepth 1 -maxdepth 1 -type d ! -name '.*' -exec basename {} \;)
hostdevice="$1"
if [[ $hostdevice == "" ]]; then
if [[ $(hostname) = *laptop ]]; then
hostdevice="laptop"
elif [[ $(hostname) = *pc ]]; then
hostdevice="pc"
fi
fi
echo "host $hostdevice"
pushd "$DOTFILES" > /dev/null
for folder in $STOW_FOLDERS
do
if [[ "$JUST_CORE" = "true" && ! "$folder" =~ ^(bin|nvim|tmux|xterm|zsh)$ ]]; then
continue
fi
if [[ $folder = *"-laptop" ]] || [[ $folder = *"-pc" ]]; then
if [[ $hostdevice == "" ]] || [[ $folder != *$hostdevice ]]; then
echo "skip $folder"
continue
fi
fi
echo "stow $folder"
if [[ $folder = *"-usr"* ]]; then
sudo stow -D -t /usr/ "$folder"
sudo stow --adopt -t /usr/ "$folder"
elif [[ $folder = *"-etc"* ]]; then
sudo stow -D -t /etc/ "$folder"
sudo stow --adopt -t /etc/ "$folder"
else
stow -D "$folder"
stow --adopt "$folder"
fi
done
git reset --hard
popd > /dev/null