-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·53 lines (44 loc) · 1.16 KB
/
install.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
#!/bin/sh
SKIP_DIRS="
OS-config
"
INSTALLER_ROOT=$(dirname "$(realpath "$0")")
FLAG_HELP="-h"
FLAG_UNINSTALL="-x"
MSG_INSTALL="installing"
MSG_UNINSTALL="uninstalling"
CMD_INSTALL="stow -d '$INSTALLER_ROOT' -t '$HOME'"
CMD_UNINSTALL="$CMD_INSTALL -D"
case "$1" in
"$FLAG_HELP")
printf "%s: installs dotfiles\n" "$0"
printf " %s show this help\n" "$FLAG_HELP"
printf " %s uninstall config (remove symlinks)\n" "$FLAG_UNINSTALL"
printf "requires 'stow' to work. run w/o args to install to \$HOME.\n"
exit 0
;;
"$FLAG_UNINSTALL")
msg="$MSG_UNINSTALL"
alias stow_cmd="$CMD_UNINSTALL"
;;
"")
msg="$MSG_INSTALL"
alias stow_cmd="$CMD_INSTALL"
;;
*)
printf "unknown option: %s\n" "$1"
printf "\n"
printf "run \"%s %s\" to view help\n" "$0" "$FLAG_HELP"
exit 1
;;
esac
for dot in "$INSTALLER_ROOT"/*/; do
config_name="$(basename "$dot")"
if ! (echo "$SKIP_DIRS" | grep -q "^$config_name$"); then
printf "%s: %s\n" "$msg" "$config_name"
stow_cmd "$config_name"
fi
done
if [ "$msg" = "$MSG_INSTALL" ] && ! [ -f ~/.zshenv ]; then
printf ". ~/.config/zsh/.zshenv\n" > ~/.zshenv
fi