-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·1181 lines (1023 loc) · 41.1 KB
/
bootstrap.sh
File metadata and controls
executable file
·1181 lines (1023 loc) · 41.1 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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# ============================================================================
# pseudobun's dotfiles - Interactive Bootstrap Install Wizard
# ============================================================================
#
# Usage:
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/pseudobun/dotfiles/main/bootstrap.sh)"
#
# Or locally:
# ./bootstrap.sh
#
# ============================================================================
set -uo pipefail
# --- Global State ---
dotfiles_path=~/.dotfiles
# --- Colors & Formatting ---
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BOLD='\033[1m'
DIM='\033[2m'
NC='\033[0m'
# --- Helper Functions ---
info() { echo -e " ${BLUE}[INFO]${NC} $1"; }
success() { echo -e " ${GREEN}[ OK ]${NC} $1"; }
warn() { echo -e " ${YELLOW}[WARN]${NC} $1"; }
err() { echo -e " ${RED}[ ERR]${NC} $1"; }
fatal() {
echo ""
echo -e " ${RED}[FATAL]${NC} $1"
echo -e " ${RED}Aborting installation.${NC}"
exit 1
}
print_header() {
echo ""
echo -e "${CYAN}${BOLD} _ _ __ _ _"
echo -e "${CYAN}${BOLD} __| | ___ | |_ / _(_) | ___ ___"
echo -e "${CYAN}${BOLD} / _\` |/ _ \\| __| |_| | |/ _ \\/ __|"
echo -e "${CYAN}${BOLD}| (_| | (_) | |_| _| | | __/\\__ \\"
echo -e "${CYAN}${BOLD} \\__,_|\\___/ \\__|_| |_|_|\\___||___/"
echo ""
echo -e " ${BOLD}pseudobun's dotfiles - Install Wizard${NC}"
echo ""
}
print_section() {
echo ""
echo -e "${BLUE}──────────────────────────────────────────────────────────${NC}"
echo -e " ${BOLD}$1${NC}"
echo -e "${BLUE}──────────────────────────────────────────────────────────${NC}"
echo ""
}
# Ask yes/no. Returns 0 for yes, 1 for no.
# Usage: ask_yes_no "Question?" [default: y|n]
ask_yes_no() {
local question="$1"
local default="${2:-y}"
local hint
if [[ "$default" == "y" ]]; then
hint="[Y/n]"
else
hint="[y/N]"
fi
while true; do
echo -en " ${BOLD}${question} ${hint}: ${NC}"
read -r answer
answer="${answer:-$default}"
case "$answer" in
[Yy]|[Yy][Ee][Ss]) return 0 ;;
[Nn]|[Nn][Oo]) return 1 ;;
*) echo " Please answer y or n." ;;
esac
done
}
# Prompt user for input with a default value.
# Usage: ask_input "Prompt" "default_value" -> prints to stdout
ask_input() {
local question="$1"
local default="$2"
echo -en " ${BOLD}${question} (default: ${default}): ${NC}" >&2
read -r answer
echo "${answer:-$default}"
}
# Wait for user to complete manual steps. Returns 0 if done, 1 if skipped.
wait_for_manual_step() {
echo ""
echo -en " ${YELLOW}Press Enter when done, or 's' to skip: ${NC}"
read -r answer
if [[ "$answer" == "s" || "$answer" == "S" ]]; then
warn "Manual step skipped."
return 1
fi
return 0
}
# ============================================================================
# Step 1: Xcode Command Line Tools (REQUIRED)
# ============================================================================
step_xcode_tools() {
print_section "Step 1/17: Xcode Command Line Tools (REQUIRED)"
if command -v xcode-select &>/dev/null && xcode-select -p &>/dev/null; then
success "Xcode CLI tools are already installed."
info "Run 'xcode-select --install' to update if needed."
return 0
fi
info "Xcode CLI tools are required for compilers, git, and other build tools."
echo ""
if ! ask_yes_no "Install Xcode CLI tools?"; then
fatal "Xcode CLI tools are required. Cannot continue without them."
fi
xcode-select --install 2>/dev/null || true
info "Waiting for Xcode CLI installation to complete..."
info "A system dialog should appear. Follow the prompts."
until xcode-select -p &>/dev/null; do
sleep 5
done
success "Xcode CLI tools installed."
}
# ============================================================================
# Step 2: Clone Dotfiles Repository (REQUIRED)
# ============================================================================
step_clone_dotfiles() {
print_section "Step 2/17: Clone Dotfiles Repository (REQUIRED)"
dotfiles_path=$(ask_input "Path to clone dotfiles" "$dotfiles_path")
if [[ -d "$dotfiles_path" ]]; then
warn "Directory '$dotfiles_path' already exists."
if ask_yes_no "Use existing directory?"; then
cd "$dotfiles_path" || fatal "Cannot enter directory '$dotfiles_path'."
success "Using existing dotfiles at: $(pwd)"
return 0
fi
if ask_yes_no "Remove and re-clone?" "n"; then
rm -rf "$dotfiles_path"
else
fatal "Cannot continue without a dotfiles directory."
fi
fi
info "Cloning https://github.com/pseudobun/dotfiles.git ..."
if ! git clone https://github.com/pseudobun/dotfiles.git "$dotfiles_path"; then
fatal "Failed to clone dotfiles repository."
fi
cd "$dotfiles_path" || fatal "Cannot enter directory '$dotfiles_path'."
success "Dotfiles cloned to: $(pwd)"
}
# ============================================================================
# Step 3: Homebrew & Packages
# ============================================================================
step_homebrew() {
print_section "Step 3/17: Homebrew & Packages"
info "This step will:"
echo " 1. Install or update Homebrew"
echo " 2. Install all packages from Brewfile"
echo " (formulae, casks, App Store apps, VS Code extensions)"
echo ""
warn "This may take a long time depending on the number of packages."
echo ""
if ! ask_yes_no "Proceed with Homebrew setup?"; then
warn "Skipped Homebrew. Many later steps depend on packages from the Brewfile."
return 0
fi
if ! command -v brew &>/dev/null; then
info "Installing Homebrew..."
if ! /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then
fatal "Homebrew installation failed."
fi
# Add Homebrew to PATH for the current session
if [[ -f /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -f /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
success "Homebrew installed."
else
info "Homebrew already installed. Updating..."
brew update && brew upgrade || warn "Homebrew update encountered issues."
success "Homebrew updated."
fi
info "Installing packages from Brewfile (this may take a while)..."
if ! brew bundle --file "$dotfiles_path/Brewfile"; then
warn "Some Brewfile packages failed. Review the output above."
else
success "All Brewfile packages installed."
fi
}
# ============================================================================
# Step 4: Shell Setup (Fish, Oh-My-Fish, Fisher)
# ============================================================================
step_shell_setup() {
print_section "Step 4/17: Shell Setup"
info "This step will:"
echo " 1. Set Fish as your default shell"
echo " 2. (Optional) Install Oh-My-Fish — experimental"
echo " 3. Install Fisher plugin manager"
echo " 4. Install Fisher plugins (pnpm-shell-completion)"
echo ""
if ! ask_yes_no "Set up Fish shell environment?"; then
warn "Skipped shell setup."
return 0
fi
# --- Fish as default shell ---
local fish_path
fish_path="$(which fish 2>/dev/null)" || true
if [[ -z "$fish_path" ]]; then
warn "Fish shell not found. Did the Homebrew step complete?"
warn "Skipping shell setup."
return 0
fi
if [[ "$SHELL" == "$fish_path" ]]; then
success "Fish is already the default shell."
elif ask_yes_no "Set Fish as your default shell?"; then
if ! grep -qF "$fish_path" /etc/shells 2>/dev/null; then
echo "$fish_path" | sudo tee -a /etc/shells >/dev/null || fatal "Failed to add Fish to /etc/shells (needs sudo)."
fi
if ! chsh -s "$fish_path"; then
err "Failed to change default shell. You can do it manually: chsh -s $fish_path"
else
success "Fish set as default shell."
fi
fi
# --- Oh-My-Fish ---
if ask_yes_no "Install Oh-My-Fish? (EXPERIMENTAL)" "n"; then
info "Installing Oh-My-Fish..."
if curl -sL https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish; then
success "Oh-My-Fish installed."
else
warn "Oh-My-Fish installation had issues."
fi
fi
# --- Fisher ---
if ask_yes_no "Install Fisher plugin manager?"; then
info "Installing Fisher..."
if fish -c 'curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher'; then
success "Fisher installed."
else
warn "Fisher installation had issues."
fi
if ask_yes_no "Install Fisher plugins (pnpm-shell-completion)?"; then
if fish -c 'fisher install g-plane/pnpm-shell-completion'; then
success "Fisher plugins installed."
else
warn "Fisher plugin installation had issues."
fi
fi
fi
}
# ============================================================================
# Step 5: GPG Setup
# ============================================================================
step_gpg_setup() {
print_section "Step 5/17: GPG Setup"
info "This step will:"
echo " 1. Configure GPG agent with pinentry-mac"
echo " 2. Set GPG defaults (use-agent, no-emit-version)"
echo " 3. Optionally import existing GPG keys from file"
echo " 4. Optionally generate a new GPG key pair"
echo " 5. Set a default signing key for git"
echo ""
if ! ask_yes_no "Set up GPG?"; then
warn "Skipped GPG setup."
return 0
fi
# --- GPG directories ---
if [[ ! -d ~/.gnupg ]]; then
mkdir -p ~/.gnupg && chmod 700 ~/.gnupg
info "Created ~/.gnupg directory."
fi
local gpg_agent_conf=~/.gnupg/gpg-agent.conf
local gpg_conf=~/.gnupg/gpg.conf
touch "$gpg_agent_conf" "$gpg_conf"
# --- pinentry-mac ---
if command -v brew &>/dev/null; then
local pinentry_path
pinentry_path="$(brew --prefix)/bin/pinentry-mac"
if [[ -f "$pinentry_path" ]]; then
if ! grep -qF "pinentry-program" "$gpg_agent_conf" 2>/dev/null; then
echo "pinentry-program $pinentry_path" >> "$gpg_agent_conf"
success "Configured pinentry-mac."
else
info "pinentry-program already configured."
fi
else
warn "pinentry-mac not found at $pinentry_path. Skipping."
fi
fi
# --- GPG defaults ---
grep -qF "use-agent" "$gpg_conf" 2>/dev/null || echo "use-agent" >> "$gpg_conf"
grep -qF "no-emit-version" "$gpg_conf" 2>/dev/null || echo "no-emit-version" >> "$gpg_conf"
success "GPG base configuration written."
# --- Key management ---
echo ""
info "GPG key options:"
echo " a) Import existing keys from file"
echo " b) Generate a new key pair"
echo " c) Skip — use pre-configured default key"
echo ""
if ask_yes_no "Import existing GPG keys from file?" "n"; then
echo -en " ${BOLD}Path to public key file (Enter to skip): ${NC}"
read -r pub_key_path
if [[ -n "$pub_key_path" ]]; then
if [[ ! -f "$pub_key_path" ]]; then
err "File not found: $pub_key_path"
elif gpg --import "$pub_key_path" 2>/dev/null; then
success "Public key imported."
else
warn "Failed to import public key."
fi
fi
echo -en " ${BOLD}Path to private key file (Enter to skip): ${NC}"
read -r priv_key_path
if [[ -n "$priv_key_path" ]]; then
if [[ ! -f "$priv_key_path" ]]; then
err "File not found: $priv_key_path"
elif gpg --import "$priv_key_path" 2>/dev/null; then
success "Private key imported."
else
warn "Failed to import private key."
fi
fi
# Pick default key
if ask_yes_no "Set a default GPG signing key for git?"; then
echo ""
info "Available secret keys:"
gpg --list-secret-keys --keyid-format=long 2>/dev/null || true
echo ""
echo -en " ${BOLD}Enter key ID to use as default (Enter to skip): ${NC}"
read -r key_id
if [[ -n "$key_id" ]]; then
# Replace or add default-key line
if grep -qF "default-key" "$gpg_conf" 2>/dev/null; then
sed -i.bak "s/^default-key.*/default-key $key_id/" "$gpg_conf" && rm -f "$gpg_conf.bak"
else
echo "default-key $key_id" >> "$gpg_conf"
fi
success "Default GPG key set to $key_id."
fi
fi
elif ask_yes_no "Generate a new GPG key pair?" "n"; then
info "Launching GPG key generation wizard..."
if gpg --full-generate-key; then
success "GPG key generated."
echo ""
info "Your secret keys:"
gpg --list-secret-keys --keyid-format=long 2>/dev/null || true
echo ""
if ask_yes_no "Set the new key as default for git signing?"; then
echo -en " ${BOLD}Enter the key ID from above: ${NC}"
read -r key_id
if [[ -n "$key_id" ]]; then
if grep -qF "default-key" "$gpg_conf" 2>/dev/null; then
sed -i.bak "s/^default-key.*/default-key $key_id/" "$gpg_conf" && rm -f "$gpg_conf.bak"
else
echo "default-key $key_id" >> "$gpg_conf"
fi
success "Default GPG key set to $key_id."
fi
fi
else
warn "GPG key generation failed or was cancelled."
fi
else
# Fall back to the pre-configured key
if ! grep -qF "default-key" "$gpg_conf" 2>/dev/null; then
echo "default-key 7A5C62926461D990A0575C9EA03490EFF21E32E9" >> "$gpg_conf"
fi
info "Using pre-configured default GPG key."
fi
success "GPG setup complete."
}
# ============================================================================
# Step 6: SSH Key Setup
# ============================================================================
step_ssh_setup() {
print_section "Step 6/17: SSH Key Setup"
info "This step will:"
echo " 1. Generate a new SSH key pair OR import existing keys"
echo " 2. Add the key to the SSH agent"
echo " 3. Configure macOS Keychain integration"
echo " 4. Display the public key for adding to GitHub, etc."
echo ""
if ! ask_yes_no "Set up SSH keys?" "n"; then
warn "Skipped SSH setup."
return 0
fi
local ssh_key_path=""
if ask_yes_no "Generate a new SSH key pair?"; then
echo -en " ${BOLD}Email address for the key: ${NC}"
read -r ssh_email
if [[ -z "$ssh_email" ]]; then
warn "No email provided. Skipping SSH key generation."
return 0
fi
ssh_key_path=$(ask_input "Key file path" "$HOME/.ssh/id_ed25519")
if [[ -f "$ssh_key_path" ]]; then
warn "Key already exists at $ssh_key_path."
if ! ask_yes_no "Overwrite?" "n"; then
info "Keeping existing key."
# Still set path so we can add to agent
else
mkdir -p "$(dirname "$ssh_key_path")"
if ! ssh-keygen -t ed25519 -C "$ssh_email" -f "$ssh_key_path"; then
err "SSH key generation failed."
return 0
fi
success "SSH key generated at $ssh_key_path."
fi
else
mkdir -p "$(dirname "$ssh_key_path")"
if ! ssh-keygen -t ed25519 -C "$ssh_email" -f "$ssh_key_path"; then
err "SSH key generation failed."
return 0
fi
success "SSH key generated at $ssh_key_path."
fi
elif ask_yes_no "Import existing SSH keys from file?" "n"; then
echo -en " ${BOLD}Path to private key: ${NC}"
read -r import_priv
echo -en " ${BOLD}Path to public key: ${NC}"
read -r import_pub
if [[ ! -f "$import_priv" ]]; then
err "Private key not found: $import_priv"
return 0
fi
if [[ ! -f "$import_pub" ]]; then
err "Public key not found: $import_pub"
return 0
fi
mkdir -p ~/.ssh
cp "$import_priv" ~/.ssh/ && chmod 600 ~/.ssh/"$(basename "$import_priv")"
cp "$import_pub" ~/.ssh/ && chmod 644 ~/.ssh/"$(basename "$import_pub")"
ssh_key_path=~/.ssh/"$(basename "$import_priv")"
success "SSH keys imported to ~/.ssh/."
else
warn "Skipped SSH key setup."
return 0
fi
# --- Add to agent ---
if [[ -n "$ssh_key_path" && -f "$ssh_key_path" ]]; then
info "Starting SSH agent and adding key..."
eval "$(ssh-agent -s)" >/dev/null 2>&1
# macOS Keychain integration
if [[ "$(uname)" == "Darwin" ]]; then
local ssh_config=~/.ssh/config
mkdir -p ~/.ssh
if [[ ! -f "$ssh_config" ]] || ! grep -qF "AddKeysToAgent" "$ssh_config" 2>/dev/null; then
cat >> "$ssh_config" <<SSHEOF
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile $ssh_key_path
SSHEOF
info "Configured macOS Keychain integration in ~/.ssh/config."
fi
fi
ssh-add "$ssh_key_path" 2>/dev/null && success "Key added to SSH agent." || warn "Could not add key to agent."
fi
# --- Display public key ---
local pub_key_path="${ssh_key_path}.pub"
if [[ -f "$pub_key_path" ]]; then
echo ""
info "Your public SSH key (add to GitHub at https://github.com/settings/keys):"
echo ""
echo -e " ${DIM}$(cat "$pub_key_path")${NC}"
echo ""
fi
}
# ============================================================================
# Step 7: Symlink Dotfiles
# ============================================================================
step_symlink_dotfiles() {
print_section "Step 7/17: Symlink Dotfiles"
info "This step will create symlinks for:"
echo " - .gitconfig -> ~/.gitconfig"
echo " - Fish functions -> ~/.config/fish/functions/"
echo " - starship.toml -> ~/.config/"
echo " - alacritty.toml -> ~/.config/alacritty/"
echo " - Sketchybar config -> ~/.config/sketchybar/"
echo " - Borders config -> ~/.config/borders/"
echo " - Yabai & skhd config -> ~/ "
echo " - Hammerspoon config -> ~/.hammerspoon/"
echo " - pseudobun.fish -> ~/.config/fish/"
echo " - fish/config.fish -> ~/.config/fish/config.fish"
echo " - fish/conf.d/* -> ~/.config/fish/conf.d/"
echo " + Download Sketchybar app font"
echo ""
if ! ask_yes_no "Create dotfile symlinks?"; then
warn "Skipped symlinks."
return 0
fi
info "Creating symlinks..."
# .gitconfig
ln -fs "$dotfiles_path/.gitconfig" ~/.gitconfig \
&& success ".gitconfig linked" \
|| warn ".gitconfig symlink failed"
# Fish functions
mkdir -p ~/.config/fish/functions
ln -fs "$dotfiles_path"/functions/* ~/.config/fish/functions/ \
&& success "Fish functions linked" \
|| warn "Fish functions symlink failed"
# Starship
mkdir -p ~/.config
ln -fs "$dotfiles_path/starship.toml" ~/.config/ \
&& success "starship.toml linked" \
|| warn "starship.toml symlink failed"
# Alacritty
mkdir -p ~/.config/alacritty
ln -fs "$dotfiles_path/alacritty/alacritty.toml" ~/.config/alacritty/alacritty.toml \
&& success "alacritty.toml linked" \
|| warn "alacritty.toml symlink failed"
# Sketchybar
mkdir -p ~/.config/sketchybar/{plugins,items,helper}
ln -fs "$dotfiles_path/sketchybar/sketchybarrc" ~/.config/sketchybar/sketchybarrc
ln -fs "$dotfiles_path/sketchybar/colors.sh" ~/.config/sketchybar/colors.sh
ln -fs "$dotfiles_path/sketchybar/icons.sh" ~/.config/sketchybar/icons.sh
ln -fs "$dotfiles_path"/sketchybar/helper/* ~/.config/sketchybar/helper/
ln -fs "$dotfiles_path"/sketchybar/plugins/* ~/.config/sketchybar/plugins/
ln -fs "$dotfiles_path"/sketchybar/items/* ~/.config/sketchybar/items/
success "Sketchybar config linked"
# Borders
mkdir -p ~/.config/borders
ln -fs "$dotfiles_path/borders/bordersrc" ~/.config/borders/bordersrc \
&& success "bordersrc linked" \
|| warn "bordersrc symlink failed"
# Hammerspoon
mkdir -p ~/.hammerspoon
ln -fs "$dotfiles_path"/.hammerspoon/* ~/.hammerspoon/ \
&& success "Hammerspoon config linked" \
|| warn "Hammerspoon symlink failed"
# Fish config
mkdir -p ~/.config/fish/conf.d
ln -fs "$dotfiles_path/pseudobun.fish" ~/.config/fish/ \
&& success "pseudobun.fish linked" \
|| warn "pseudobun.fish symlink failed"
ln -fs "$dotfiles_path/fish/config.fish" ~/.config/fish/config.fish \
&& success "config.fish linked" \
|| warn "config.fish symlink failed"
ln -fs "$dotfiles_path"/fish/conf.d/* ~/.config/fish/conf.d/ \
&& success "fish conf.d linked" \
|| warn "fish conf.d symlink failed"
# Yabai & skhd
ln -fs "$dotfiles_path/yabai/.yabairc" ~/.yabairc \
&& success ".yabairc linked" \
|| warn ".yabairc symlink failed"
ln -fs "$dotfiles_path/yabai/.skhdrc" ~/.skhdrc \
&& success ".skhdrc linked" \
|| warn ".skhdrc symlink failed"
# Sketchybar app font (macOS only)
if [[ "$(uname)" == "Darwin" ]]; then
info "Downloading Sketchybar app font..."
mkdir -p "$HOME/Library/Fonts"
if curl -sL https://github.com/kvndrsslr/sketchybar-app-font/releases/download/v1.0.16/sketchybar-app-font.ttf \
-o "$HOME/Library/Fonts/sketchybar-app-font.ttf"; then
success "Sketchybar app font installed."
else
warn "Font download failed."
fi
fi
echo ""
success "Dotfile symlinks created."
}
# ============================================================================
# Step 8: Fish Shell Configuration (setup.fish)
# ============================================================================
step_fish_config() {
print_section "Step 8/17: Fish Shell Configuration"
info "This step runs setup.fish to configure:"
echo " - OMF theme (pseudobun)"
echo " - PATH additions (PostgreSQL, Cargo)"
echo " - Fisher bootstrap"
echo ""
if ! ask_yes_no "Run Fish shell configuration (setup.fish)?"; then
warn "Skipped Fish configuration."
return 0
fi
if ! command -v fish &>/dev/null; then
warn "Fish shell not found. Skipping."
return 0
fi
if fish "$dotfiles_path/setup.fish"; then
success "Fish configuration complete."
else
warn "Fish setup encountered issues."
fi
}
# ============================================================================
# Step 9: Development Tools
# ============================================================================
step_dev_tools() {
print_section "Step 9/17: Development Tools"
info "Choose which tools to install:"
echo " a) Rust — systems programming (via rustup)"
echo " b) Foundry — Ethereum / Solidity development"
echo " c) Bun — fast JavaScript runtime & bundler"
echo " d) Deno — secure JavaScript / TypeScript runtime"
echo " e) Go — requires manual download (guided)"
echo " f) asdf — multi-language version manager"
echo ""
if ! ask_yes_no "Install any development tools?"; then
warn "Skipped development tools."
return 0
fi
# --- Rust ---
if ask_yes_no "Install Rust (via rustup)?"; then
info "Installing Rust..."
if curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh; then
[[ -f "$HOME/.cargo/env" ]] && source "$HOME/.cargo/env"
if command -v rustc &>/dev/null; then
success "Rust installed: $(rustc --version)."
else
info "Rust installed. Restart your shell to use it."
fi
else
warn "Rust installation had issues."
fi
fi
# --- Foundry ---
if ask_yes_no "Install Foundry (Ethereum development)?" "n"; then
info "Installing Foundry..."
if curl -L https://foundry.paradigm.xyz | bash; then
success "Foundry bootstrap complete. Run 'foundryup' to finish setup."
else
warn "Foundry installation had issues."
fi
fi
# --- Bun ---
if ask_yes_no "Install Bun (JavaScript runtime)?"; then
info "Installing Bun..."
if curl -fsSL https://bun.sh/install | bash; then
success "Bun installed."
else
warn "Bun installation had issues."
fi
fi
# --- Deno ---
if ask_yes_no "Install Deno (JavaScript runtime)?" "n"; then
info "Installing Deno..."
if curl -fsSL https://deno.land/install.sh | sh; then
success "Deno installed."
else
warn "Deno installation had issues."
fi
fi
# --- Go (manual) ---
if ask_yes_no "Install Go? (manual download required)" "n"; then
echo ""
info "Go must be installed manually:"
echo " 1. Visit https://go.dev/dl/"
echo " 2. Download the macOS installer (.pkg) for your architecture"
echo " 3. Run the .pkg installer"
echo " 4. Verify with: go version"
echo ""
if wait_for_manual_step; then
if command -v go &>/dev/null; then
success "Go verified: $(go version)."
else
warn "Go not found in PATH. You may need to restart your shell."
fi
fi
fi
# --- asdf ---
if ask_yes_no "Install asdf (version manager)?" "n"; then
info "Installing asdf..."
if git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0; then
mkdir -p ~/.config/fish/completions
ln -s ~/.asdf/completions/asdf.fish ~/.config/fish/completions 2>/dev/null || true
success "asdf installed."
else
warn "asdf installation failed."
fi
fi
}
# ============================================================================
# Step 10: Spicetify (Spotify Customization)
# ============================================================================
step_spicetify() {
print_section "Step 10/17: Spicetify (Spotify Customization)"
info "This step will:"
echo " 1. Install Spicetify CLI"
echo " 2. Install Spicetify Marketplace plugin"
echo ""
if ! ask_yes_no "Install Spicetify?" "n"; then
warn "Skipped Spicetify."
return 0
fi
info "Installing Spicetify CLI..."
if curl -fsSL https://raw.githubusercontent.com/spicetify/cli/main/install.sh | sh; then
success "Spicetify CLI installed."
else
warn "Spicetify CLI installation failed."
fi
info "Installing Spicetify Marketplace..."
if curl -fsSL https://raw.githubusercontent.com/spicetify/marketplace/main/resources/install.sh | sh; then
success "Spicetify Marketplace installed."
else
warn "Spicetify Marketplace installation failed."
fi
}
# ============================================================================
# Step 11: macOS Defaults
# ============================================================================
step_macos_defaults() {
print_section "Step 11/17: macOS Defaults"
info "This step will apply the following preferences:"
echo " 1. Disable mouse acceleration (com.apple.mouse.scaling = -1)"
echo " 2. Set dock auto-hide delay to 50ms"
echo " 3. Enable scroll-to-open on Dock icons"
echo ""
if ! ask_yes_no "Apply macOS defaults?"; then
warn "Skipped macOS defaults."
return 0
fi
defaults write .GlobalPreferences com.apple.mouse.scaling -1 \
&& success "Mouse acceleration disabled." \
|| warn "Failed to set mouse scaling."
defaults write com.apple.dock autohide-time-modifier -float 0.05 \
&& success "Dock auto-hide delay set to 50ms." \
|| warn "Failed to set dock auto-hide."
defaults write com.apple.dock "scroll-to-open" -bool "true" \
&& success "Scroll-to-open enabled on Dock." \
|| warn "Failed to enable scroll-to-open."
info "Some changes require a logout or restart to take effect."
}
# ============================================================================
# Step 12: Terminal Applications
# ============================================================================
step_terminal_apps() {
print_section "Step 12/17: Terminal Applications"
info "Install additional terminal emulators:"
echo " - Kitty (GPU-accelerated terminal)"
echo ""
if ask_yes_no "Install Kitty terminal emulator?" "n"; then
info "Installing Kitty..."
if curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin; then
success "Kitty installed."
else
warn "Kitty installation failed."
fi
else
warn "Skipped terminal app installation."
fi
}
# ============================================================================
# Step 13: Font Installation
# ============================================================================
step_fonts() {
print_section "Step 13/17: Font Installation"
info "Liga SFMono Nerd Font is handled by the Brewfile."
info "This step installs additional bundled fonts from the repo:"
echo " - JetBrains Mono (fonts/JetBrainsMono/)"
echo " - Roboto Mono (fonts/RobotoMono/)"
echo ""
if [[ "$(uname)" != "Darwin" ]]; then
info "On non-macOS, install fonts manually from the fonts/ directory."
wait_for_manual_step || true
return 0
fi
if ! ask_yes_no "Install bundled fonts to ~/Library/Fonts/?"; then
warn "Skipped font installation."
return 0
fi
mkdir -p "$HOME/Library/Fonts"
local count=0
while IFS= read -r -d '' font_file; do
cp "$font_file" "$HOME/Library/Fonts/" && ((count++))
done < <(find "$dotfiles_path/fonts" -type f \( -name '*.ttf' -o -name '*.otf' \) -print0 2>/dev/null)
if [[ "$count" -gt 0 ]]; then
success "$count font files installed to ~/Library/Fonts/."
else
warn "No font files (.ttf/.otf) found in fonts/ directory."
fi
}
# ============================================================================
# Step 14: iTerm2 Configuration (Manual)
# ============================================================================
step_iterm_config() {
print_section "Step 14/17: iTerm2 Configuration"
info "iTerm2 settings must be imported through the app UI."
echo ""
if ! ask_yes_no "Configure iTerm2?"; then
warn "Skipped iTerm2 configuration."
return 0
fi
if [[ "$(uname)" != "Darwin" ]]; then
warn "iTerm2 is macOS-only. Skipping."
return 0
fi
if [[ ! -d "/Applications/iTerm.app" ]]; then
warn "iTerm2 is not installed. Skipping."
return 0
fi
echo ""
info "${BOLD}Step A — Import Color Scheme:${NC}"
echo " 1. Open iTerm2"
echo " 2. Go to: iTerm > Preferences > Profiles > Colors > Color Presets ..."
echo " 3. Click 'Import...' and select:"
echo " $dotfiles_path/itermcolors/DraculaPlus.itermcolors"
echo " 4. Choose 'DraculaPlus' from the Color Presets dropdown"
echo ""
info "${BOLD}Step B — Import Profile:${NC}"
echo " 5. Go to: iTerm > Preferences > Profiles"
echo " 6. Click: Other actions ... > Import JSON profiles ..."
echo " 7. Select: $dotfiles_path/profiles/pseudobun.json"
echo ""
info "${BOLD}Step C — Import Key Bindings:${NC}"
echo " 8. Go to: iTerm > Preferences > Keys > Key Bindings"
echo " 9. Click: Presets ... > Import ..."
echo " 10. Select: $dotfiles_path/profiles/pseudobun.itermkeymap"
echo ""
if wait_for_manual_step; then
if defaults read com.googlecode.iterm2 &>/dev/null 2>&1; then
success "iTerm2 preferences detected."
else
info "Could not verify iTerm2 preferences (this is normal if iTerm2 hasn't been opened yet)."
fi
fi
}
# ============================================================================
# Step 15: Raycast Configuration
# ============================================================================
step_raycast_config() {
print_section "Step 15/17: Raycast Configuration"
info "Raycast is an alternative to Spotlight."
info "Configuration file: $dotfiles_path/raycast/raycast.rayconfig"
echo ""
if ! ask_yes_no "Import Raycast configuration?"; then
warn "Skipped Raycast configuration."
return 0
fi
if [[ "$(uname)" == "Darwin" && -d "/Applications/Raycast.app" ]]; then
info "Opening Raycast config file for import..."
if open "$dotfiles_path/raycast/raycast.rayconfig" 2>/dev/null; then
info "Raycast import dialog should appear."
echo " Follow the prompts in Raycast to complete the import."
echo ""
if wait_for_manual_step; then
success "Raycast configuration imported."
fi
else
warn "Failed to open Raycast config file."
fi
else
info "Raycast not found. To import manually later:"
echo " 1. Open Raycast"
echo " 2. Import the configuration from: $dotfiles_path/raycast/raycast.rayconfig"
echo ""
wait_for_manual_step || true
fi
}
# ============================================================================
# Step 16: GitHub CLI Authentication
# ============================================================================
step_github_auth() {
print_section "Step 16/17: GitHub CLI Authentication"
info "This will authenticate the GitHub CLI (gh) for repository access."
echo ""
if ! ask_yes_no "Authenticate with GitHub CLI?"; then
warn "Skipped GitHub authentication."
return 0
fi
if ! command -v gh &>/dev/null; then
warn "GitHub CLI (gh) not found. Install via Homebrew first."
return 0