-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·313 lines (276 loc) · 10.5 KB
/
setup
File metadata and controls
executable file
·313 lines (276 loc) · 10.5 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#!/usr/bin/env zsh
################################################################################
# Setup needed variables and env #
# #
# 1. The directory of the script #
# 2. The path of the gum binary #
# #
# Then this script will take care of installing the needed fonts, and the #
# needed software and tools. #
# #
# Usage: #
# ./setup - Interactive mode: select operations to execute #
# ./setup --all - Execute all operations #
################################################################################
#####################################
# Check if the current shell is ZSH #
#####################################
if [ -z "$ZSH_VERSION" ]; then
echo ""
echo "You need to be in ZSH to launch this script."
echo "Install ZSH, then change shell:"
echo ""
echo "> chsh -s \$(which zsh)"
echo ""
echo "You need to re-login afterwards."
exit 1
fi
export DIR="${0:A:h}"
######################################################
# Import lib/oses.sh #
# Import lib/shell.sh #
# #
# they contains the functions for detecting the OS #
# and the current shell #
######################################################
source $DIR/lib/oses.sh
source $DIR/lib/shell.sh
##############################################
# Check if the operating system is supported #
##############################################
if [ $OS = "other" ]; then
echo ""
echo "This script is only for macOS and Linux systems."
echo ""
exit 1
fi
##############################################
# Parse command line arguments #
##############################################
INSTALL_ALL=false
if [[ "$1" == "--all" ]]; then
INSTALL_ALL=true
fi
##############################################
# Check if gum is available #
##############################################
GUM_AVAILABLE=false
if command -v gum &> /dev/null; then
GUM_AVAILABLE=true
else
# Try to add Homebrew to PATH if it exists
if [ -d /opt/homebrew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null
elif [ -d /home/linuxbrew/.linuxbrew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 2>/dev/null
fi
if command -v brew &> /dev/null && command -v gum &> /dev/null; then
GUM_AVAILABLE=true
fi
fi
# If gum is not available and --all is not passed, exit with message
if [ "$GUM_AVAILABLE" = false ] && [ "$INSTALL_ALL" = false ]; then
echo ""
echo "gum is not available. This script requires gum for interactive mode."
echo ""
echo "Please run the script with --all flag to execute all operations:"
echo " ./setup --all"
echo ""
exit 1
fi
##############################################
# Interactive operation selection #
##############################################
SELECTED_OPERATIONS=""
if [ "$INSTALL_ALL" = false ]; then
OPERATIONS=(
"Install Homebrew"
"Install macOS fonts and kitty"
"Install Linux make tools"
"Install brew packages (gum, git, tmux, etc.)"
"Install brew casks (ghostty)"
"Create folders"
"Install oh-my-zsh"
"Symlink dotfiles"
"Symlink binaries"
"Clone tmux TPM"
"Sync editor extensions (Cursor/VS Code)"
"Setup private dotfiles"
)
log_header "Select operations to execute (use Space to select, Enter to confirm):"
SELECTED_OPERATIONS=$(gum choose --no-limit "${OPERATIONS[@]}")
if [ -z "$SELECTED_OPERATIONS" ]; then
log_message "No operations selected. Installation aborted."
exit 1
fi
echo ""
gum style --border normal --padding "0 4" --border-foreground 212 "Selected operations:" "$SELECTED_OPERATIONS"
echo ""
if ! confirm_prompt "Continue with the selected operations?" ; then
log_message "Installation aborted."
exit 1
fi
fi
##############################################
# Helper function to check if operation #
# should be executed #
##############################################
should_execute() {
local operation_name=$1
if [ "$INSTALL_ALL" = true ]; then
return 0
else
# Check if operation is in selected list (handle newlines)
if echo "$SELECTED_OPERATIONS" | grep -Fq "$operation_name"; then
return 0
else
return 1
fi
fi
}
##########################################
# Install Homebrew (required for later) #
##########################################
if should_execute "Install Homebrew"; then
$DIR/installers/00-install-homebrew.sh
fi
##########################################
# Only on MacOS, install fonts and kitty #
##########################################
if should_execute "Install macOS fonts and kitty"; then
if [ $OS = "macos" ]; then
$DIR/installers/macos/fonts.sh
$DIR/installers/macos/kitty.sh
fi
fi
##############################################
# Only on Linux, install make tools #
##############################################
if should_execute "Install Linux make tools"; then
if [[ $OS = "linux" || $OS = "wsl" ]]; then
echo ""
echo "Installing make tools..."
echo ""
sudo apt update
sudo apt install g++ gcc make
fi
fi
##########################################
# Install gum first (needed for prompts) #
##########################################
if ! command -v gum &> /dev/null; then
# Add Homebrew to PATH if it exists
if [ -d /opt/homebrew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null
elif [ -d /home/linuxbrew/.linuxbrew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 2>/dev/null
fi
if command -v brew &> /dev/null && should_execute "Install brew packages (gum, git, tmux, etc.)"; then
echo "Installing gum (required for interactive prompts)..."
brew install gum
fi
fi
#########################
# Install brew software #
#########################
if should_execute "Install brew packages (gum, git, tmux, etc.)"; then
# Add Homebrew to PATH
if [ -d /opt/homebrew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null
elif [ -d /home/linuxbrew/.linuxbrew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 2>/dev/null
fi
if command -v brew &> /dev/null; then
brew install gum git tmux zellij \
micro \
neovim ripgrep fzf \
yt-dlp \
mailpit \
python \
go \
ffmpeg \
ansible \
yazi eza bat fd zoxide \
lazygit lazydocker difftastic \
tldr btop dust procs sd \
httpie doggo gping broot
fi
fi
######################
# Install brew casks #
######################
if should_execute "Install brew casks (ghostty)"; then
# Add Homebrew to PATH
if [ -d /opt/homebrew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null
elif [ -d /home/linuxbrew/.linuxbrew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 2>/dev/null
fi
if command -v brew &> /dev/null; then
# Install ghostty for macOS without OpenGL support
brew install --cask ghostty
# Install lazyworktree (TUI for git worktrees)
brew tap chmouel/lazyworktree https://github.com/chmouel/lazyworktree
brew install --cask lazyworktree
fi
fi
################################################################################
# #
# GUM is available, we can now start the installation process. #
# #
################################################################################
if [ "$INSTALL_ALL" = true ]; then
log_header "All dependencies are installed."
if ! confirm_prompt "Continue with the installation?" ; then
log_message "Installation aborted."
exit 1
fi
fi
##########################################
# Create folders #
##########################################
if should_execute "Create folders"; then
$DIR/installers/01-create-folders.sh
fi
##########################################
# Install oh-my-zsh #
##########################################
if should_execute "Install oh-my-zsh"; then
$DIR/installers/02-install-oh-my-zsh.sh
fi
##########################################
# Symlink dotfiles #
##########################################
if should_execute "Symlink dotfiles"; then
$DIR/installers/03-symlink-dotfiles.sh
fi
##########################################
# Symlink binaries #
##########################################
if should_execute "Symlink binaries"; then
$DIR/installers/04-symlink-binaries.sh
fi
##########################################
# Clone tmux TPM #
##########################################
if should_execute "Clone tmux TPM"; then
$DIR/installers/05-clone-tmux-tpm.sh
fi
##########################################
# Install editor extensions #
##########################################
if should_execute "Sync editor extensions (Cursor/VS Code)"; then
$DIR/installers/06-sync-editor-extensions.sh
fi
##################################################################
# If the private dotfiles repo exists, then run the setup script #
##################################################################
if should_execute "Setup private dotfiles"; then
if [ -f $DIR/dotfiles-private/setup ] ; then
log_message "Setting up private dotfiles..."
$DIR/dotfiles-private/setup
else
log_message "Private dotfiles setup not found. Skipping."
fi
fi
log_header "Installation completed!"