-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·80 lines (68 loc) · 1.88 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
INSTALL_JSON=$SCRIPT_DIR/install.json
PRESENT=false
DOT_FOLDERS="bin,assets,tmux,nvim,zsh,dev,geek"
# parse other arguments
for i in "$@"; do
case $i in
-i|--interactive)
# interactive using GUM
DOT_FOLDERS="bin,assets"
SELECTED=$(cat $INSTALL_JSON | jq -r 'keys_unsorted[]' | gum choose --limit 10)
for choice in $(echo $SELECTED | sed "s/,/ /g"); do
DOT_FOLDERS="$DOT_FOLDERS,$(cat $INSTALL_JSON | jq -r ".$choice")"
done
shift
;;
-p|--personal)
echo "Enabling Personal mode..."
DOT_FOLDERS="$DOT_FOLDERS,personal"
shift
;;
-c|--code-review|--security)
echo "Enabling Code Review mode..."
DOT_FOLDERS="$DOT_FOLDERS,security"
;;
-s|--server)
echo "Enabling Server mode..."
DOT_FOLDERS="$DOT_FOLDERS"
shift
;;
-w|--work)
echo "Enabling Work mode..."
DOT_FOLDERS="$DOT_FOLDERS,github"
shift
;;
-*|--*)
echo "Unknown option $i"
exit 1
;;
*)
;;
esac
done
echo "[+] Dotfiles :: $SCRIPT_DIR"
if ! command -v stow &> /dev/null; then
echo "The 'stow' package is required"
exit 1
fi
for folder in $(echo $DOT_FOLDERS | sed "s/,/ /g"); do
echo "[+] Folder :: $folder"
stow -t $HOME -D $folder \
--ignore=README.md --ignore=LICENSE
stow -t $HOME $folder
done
# Look for DOT_FOLDER in the .env
while IFS= read -r var; do
[[ $var =~ ^DOT_FOLDER.* ]] && PRESENT=true
done < "$HOME/.env"
# If not present, write the DOT_FOLDER var into the file
if [[ $PRESENT == "false" ]]; then
echo "[+] Adding DOT_FOLDER to .env"
echo "DOT_FOLDER=$SCRIPT_DIR" >> $HOME/.env
fi
# Reload shell once installed
echo "[+] Reloading shell..."
exec $SHELL -l