-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall
More file actions
executable file
·137 lines (119 loc) · 2.76 KB
/
install
File metadata and controls
executable file
·137 lines (119 loc) · 2.76 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env bash
# shellcheck disable=SC1091
set -e
# flags
SELECT=0
FORCE_PROFILE=0
FORCE_COMPLETIONS=0
while (($#)); do
case "$1" in
-s|--select) SELECT=1 ;;
-f|--force-profile) FORCE_PROFILE=1 ;;
-c|--force-completions) FORCE_COMPLETIONS=1 ;;
--) shift; break ;;
*) echo "unknown option: $1" >&2; exit 2 ;;
esac
shift
done
# Exported so the module install scripts have a ref to the base
SCRIPT_BASE_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
export SCRIPT_BASE_DIR
source "$SCRIPT_BASE_DIR/common" || exit 1
populate_os_zvars() {
os="$(uname -s)"
case "$os" in
Linux*)
echo "export DOTFILES_OS=Linux" > "$SCRIPT_BASE_DIR/zsh/zvars"
if command_exists pacman; then
echo "export DOTFILES_DISTRO=Arch" >> "$SCRIPT_BASE_DIR/zsh/zvars"
elif command_exists dnf; then
echo "export DOTFILES_DISTRO=Fedora" >> "$SCRIPT_BASE_DIR/zsh/zvars"
fi
;;
Darwin*)
echo "export DOTFILES_OS=OSX" > "$SCRIPT_BASE_DIR/zsh/zvars"
;;
*)
errorprint "Unsupported OS: $os"
exit 1
;;
esac
}
populate_profile_zvars() {
choices=("personal" "work" "hybrid")
if command_exists fzf; then
profile=$(printf "%s\n" "${choices[@]}" | fzf --prompt="Select profile: ")
else
echo "Select profile:"
select opt in "${choices[@]}"; do
if [[ -n "$opt" ]]; then
profile="$opt"
break
fi
done
fi
# If user aborted, bail
if [[ -z "${profile:-}" ]]; then
errorprint "No profile selected."
exit 1
fi
echo "export DOTFILES_PROFILE=$profile" >> "$SCRIPT_BASE_DIR/zsh/zvars"
}
populate_os_zvars
if [[ -z "${DOTFILES_PROFILE:-}" || "$FORCE_PROFILE" -eq 1 ]]; then
populate_profile_zvars
else # the file gets re-created
echo "export DOTFILES_PROFILE=$DOTFILES_PROFILE" >> "$SCRIPT_BASE_DIR/zsh/zvars"
fi
source "$SCRIPT_BASE_DIR/zsh/zvars"
infoprint "[main] configured & loaded zvars"
modules_to_install=(
system # always first!
zsh
mise
ruby
go
python
node
git
sublime
mpd
ghostty
hyprland
waybar
mpv
nnn
thunar
ripgrep
nvim
rofi
dunst
opencode
tailscale
mybin
bat
fd
dnie
flashspace
firefox
)
# interactively pick modules
if (( SELECT )); then
if ! command_exists fzf; then
errorprint "error: --select/-s requires fzf"
exit 1
fi
choices=$(printf "%s\n" "${modules_to_install[@]}" | sort -r | fzf -m --bind enter:accept-non-empty --prompt="Select modules to install > ")
modules_to_install=( $(echo "$choices") )
fi
for module in "${modules_to_install[@]}"; do
infoprint "[$module] installing..."
bash "$SCRIPT_BASE_DIR/$module/__install"
infoprint "[main] $module done"
done
# Usually don't want to re-gen global completions just for a few modules??
if (( !SELECT || FORCE_COMPLETIONS )); then
infoprint "[main] generating completions"
"$SCRIPT_BASE_DIR/mybin/both/compupdate"
fi
infoprint "[main] done"