-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·1333 lines (1187 loc) · 46.5 KB
/
install.sh
File metadata and controls
executable file
·1333 lines (1187 loc) · 46.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
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
#!/usr/bin/env bash
set -euo pipefail
# Shell Configuration installer for Fish/Zsh Shell and modern development tools
# Installs and configures Fish or Zsh shell, Starship prompt, and modern CLI tools
# Color codes for terminal output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m' # No Color
# Emoji indicators
SUCCESS="✅"
ERROR="❌"
WARNING="⚠️"
INFO="ℹ️"
ROCKET="🚀"
# Path validation function to prevent directory traversal and injection attacks
validate_path() {
local path="$1"
local description="${2:-path}"
# Check for directory traversal attempts
if [[ "$path" == *".."* ]]; then
printf "${RED}${ERROR} Invalid %s: Path cannot contain '..' (directory traversal)${NC}\n" "$description" >&2
return 1
fi
# Check for absolute paths
if [[ "$path" == "/"* ]]; then
printf "${RED}${ERROR} Invalid %s: Path cannot be absolute${NC}\n" "$description" >&2
return 1
fi
# Check for path starting with tilde (home directory expansion)
if [[ "$path" == "~"* ]]; then
printf "${RED}${ERROR} Invalid %s: Path cannot start with '~'${NC}\n" "$description" >&2
return 1
fi
# Check for command injection characters in filenames
# These characters pose significant security risks in shell contexts
if [[ "$path" == *";"* ]] || [[ "$path" == *"|"* ]] || [[ "$path" == *"&"* ]] || \
[[ "$path" == *'`'* ]] || [[ "$path" == *'$('* ]] || [[ "$path" == *">"* ]] || \
[[ "$path" == *"<"* ]]; then
printf "${RED}${ERROR} Invalid %s: Path contains potentially dangerous characters${NC}\n" "$description" >&2
return 1
fi
return 0
}
# Print colored output
print_color() {
local color=$1
shift
printf "${color}%s${NC}\n" "$*"
}
# Print status messages
log_success() { printf "${GREEN}${SUCCESS} %s${NC}\n" "$*"; }
log_error() { printf "${RED}${ERROR} %s${NC}\n" "$*" >&2; }
log_warning() { printf "${YELLOW}${WARNING} %s${NC}\n" "$*"; }
log_info() { printf "${CYAN}${INFO} %s${NC}\n" "$*"; }
# Display ASCII art with gradient colors
show_banner() {
printf "\n"
printf "${BLUE}███████${CYAN}╗██${GREEN}╗ ██${YELLOW}╗███████${MAGENTA}╗██${RED}╗ ██${BLUE}╗ ${NC}\n"
printf "${BLUE}██${CYAN}╔════╝██${GREEN}║ ██${YELLOW}║██${MAGENTA}╔════╝██${RED}║ ██${BLUE}║ ${NC}\n"
printf "${BLUE}███████${CYAN}╗███████${GREEN}║█████${YELLOW}╗ ██${MAGENTA}║ ██${RED}║ ${NC}\n"
printf "${BLUE}╚════██${CYAN}║██${GREEN}╔══██║██${YELLOW}╔══╝ ██${MAGENTA}║ ██${RED}║ ${NC}\n"
printf "${BLUE}███████${CYAN}║██${GREEN}║ ██║███████${YELLOW}╗███████${MAGENTA}╗███████${RED}╗${NC}\n"
printf "${BLUE}╚══════${CYAN}╝╚═${GREEN}╝ ╚═╝╚══════${YELLOW}╝╚══════${MAGENTA}╝╚══════${RED}╝${NC}\n"
printf "\n"
printf "${BOLD}${MAGENTA}╔═════════════════════════════════╗${NC}\n"
printf "${BOLD}${CYAN}║ Modern Shell Configuration ║${NC}\n"
printf "${BOLD}${MAGENTA}╚═════════════════════════════════╝${NC}\n"
printf "\n"
}
# Check for required dependencies
check_dependencies() {
local missing_deps=()
for cmd in curl git; do
if ! command -v "$cmd" >/dev/null 2>&1; then
missing_deps+=("$cmd")
fi
done
if [ ${#missing_deps[@]} -gt 0 ]; then
log_error "Missing required dependencies: ${missing_deps[*]}"
log_info "Please install the missing tools and try again."
# Provide installation hints
if [[ "$OSTYPE" == "darwin"* ]]; then
log_info "On macOS, you can install with: xcode-select --install"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
log_info "On Linux, install with your package manager (apt, yum, etc.)"
fi
exit 1
fi
}
# Detect the script directory
script_dir() {
local src="$0"
while [ -h "$src" ]; do
local dir
dir=$(cd -P "$(dirname "$src")" && pwd)
src=$(readlink "$src")
case $src in
/*) ;;
*) src="$dir/$src" ;;
esac
done
cd -P "$(dirname "$src")" >/dev/null 2>&1 && pwd
}
# Backup file if it exists
backup_file() {
local file="$1"
if [ -f "$file" ]; then
local backup="${file}.backup.$(date +%Y%m%d_%H%M%S)"
cp "$file" "$backup"
log_info "Backed up existing file to: $backup"
fi
}
# Install Fish configuration
install_fish_config() {
local config_base="$1"
local force_overwrite="$2"
local dry_run="$3"
if [[ "$dry_run" -eq 1 ]]; then
if [[ -f "$config_base/fish/config.fish" ]] || [[ -d "$config_base/fish/conf.d" ]]; then
print_color "$BOLD" " 🐟 Fish Configuration:"
# Main config
if [ -f "$config_base/fish/config.fish" ]; then
local target_file=~/.config/fish/config.fish
if [ -f "$target_file" ]; then
print_color "$YELLOW" " ⚠️ config.fish (already exists)"
else
print_color "$GREEN" " + config.fish (new file)"
fi
fi
# Conf.d modules
if [ -d "$config_base/fish/conf.d" ]; then
find "$config_base/fish/conf.d" -name "*.fish" -type f | sort | while read conf_file; do
local conf_name=$(basename "$conf_file")
local target_file=~/.config/fish/conf.d/"$conf_name"
if [ -f "$target_file" ]; then
print_color "$YELLOW" " ⚠️ conf.d/$conf_name (already exists)"
else
print_color "$GREEN" " + conf.d/$conf_name (new file)"
fi
done
fi
printf "\n"
fi
else
# Actual installation for Fish
if [[ -f "$config_base/fish/config.fish" ]] || [[ -d "$config_base/fish/conf.d" ]]; then
log_info "Installing Fish configuration..."
# Copy main config
if [ -f "$config_base/fish/config.fish" ]; then
local target_file=~/.config/fish/config.fish
if [ -f "$target_file" ]; then
# Check if the existing file is different from our new one
if ! cmp -s "$config_base/fish/config.fish" "$target_file"; then
backup_file "$target_file"
cp "$config_base/fish/config.fish" "$target_file"
log_success " → config.fish updated (old version backed up)"
else
log_success " → config.fish already up to date"
fi
else
cp "$config_base/fish/config.fish" "$target_file"
log_success " → config.fish installed"
fi
fi
# Copy conf.d modules
if [ -d "$config_base/fish/conf.d" ]; then
mkdir -p ~/.config/fish/conf.d
find "$config_base/fish/conf.d" -name "*.fish" -type f | sort | while read conf_file; do
local conf_name=$(basename "$conf_file")
local target_file=~/.config/fish/conf.d/"$conf_name"
if [ -f "$target_file" ]; then
if [ "$force_overwrite" -eq 0 ]; then
backup_file "$target_file"
fi
cp "$conf_file" "$target_file"
log_success " → conf.d/$conf_name updated"
else
cp "$conf_file" "$target_file"
log_success " → conf.d/$conf_name installed"
fi
done
fi
fi
fi
}
# Install Bash configuration
install_bash_config() {
local config_base="$1"
local force_overwrite="$2"
local dry_run="$3"
if [[ "$dry_run" -eq 1 ]]; then
# Dry run for Bash
if [[ -f "$config_base/bash/.bashrc" ]] || [[ -f "$config_base/bash/.bash_profile" ]] || [[ -d "$config_base/bash/conf.d" ]]; then
print_color "$BOLD" " 🐚 Bash Configuration:"
# Main .bashrc
if [ -f "$config_base/bash/.bashrc" ]; then
local target_file=~/.bashrc
if [ -f "$target_file" ]; then
print_color "$YELLOW" " ⚠️ .bashrc (already exists)"
else
print_color "$GREEN" " + .bashrc (new file)"
fi
fi
# .bash_profile
if [ -f "$config_base/bash/.bash_profile" ]; then
local target_file=~/.bash_profile
if [ -f "$target_file" ]; then
print_color "$YELLOW" " ⚠️ .bash_profile (already exists)"
else
print_color "$GREEN" " + .bash_profile (new file)"
fi
fi
# Conf.d modules
if [ -d "$config_base/bash/conf.d" ]; then
find "$config_base/bash/conf.d" -name "*.bash" -type f | sort | while read conf_file; do
local conf_name=$(basename "$conf_file")
local target_file=~/.config/bash/conf.d/"$conf_name"
if [ -f "$target_file" ]; then
print_color "$YELLOW" " ⚠️ conf.d/$conf_name (already exists)"
else
print_color "$GREEN" " + conf.d/$conf_name (new file)"
fi
done
fi
printf "\n"
fi
else
# Actual installation for Bash
if [[ -f "$config_base/bash/.bashrc" ]] || [[ -f "$config_base/bash/.bash_profile" ]] || [[ -d "$config_base/bash/conf.d" ]]; then
log_info "Installing Bash configuration..."
# Copy main .bashrc
if [ -f "$config_base/bash/.bashrc" ]; then
local target_file=~/.bashrc
if [ -f "$target_file" ] && [ "$force_overwrite" -eq 0 ]; then
backup_file "$target_file"
fi
cp "$config_base/bash/.bashrc" "$target_file"
log_success " → .bashrc installed"
fi
# Copy .bash_profile
if [ -f "$config_base/bash/.bash_profile" ]; then
local target_file=~/.bash_profile
if [ -f "$target_file" ] && [ "$force_overwrite" -eq 0 ]; then
backup_file "$target_file"
fi
cp "$config_base/bash/.bash_profile" "$target_file"
log_success " → .bash_profile installed"
fi
# Copy conf.d modules
if [ -d "$config_base/bash/conf.d" ]; then
mkdir -p ~/.config/bash/conf.d
find "$config_base/bash/conf.d" -name "*.bash" -type f | sort | while read conf_file; do
local conf_name=$(basename "$conf_file")
local target_file=~/.config/bash/conf.d/"$conf_name"
if [ -f "$target_file" ] && [ "$force_overwrite" -eq 0 ]; then
backup_file "$target_file"
fi
cp "$conf_file" "$target_file"
log_success " → conf.d/$conf_name installed"
done
fi
fi
fi
}
# Install Zsh configuration
install_zsh_config() {
local config_base="$1"
local force_overwrite="$2"
local dry_run="$3"
if [[ "$dry_run" -eq 1 ]]; then
# Dry run for Zsh
if [[ -f "$config_base/zsh/.zshrc" ]] || [[ -d "$config_base/zsh/conf.d" ]]; then
print_color "$BOLD" " 🚀 Zsh Configuration:"
# Main .zshrc
if [ -f "$config_base/zsh/.zshrc" ]; then
local target_file=~/.zshrc
if [ -f "$target_file" ]; then
print_color "$YELLOW" " ⚠️ .zshrc (already exists)"
else
print_color "$GREEN" " + .zshrc (new file)"
fi
fi
# Conf.d modules
if [ -d "$config_base/zsh/conf.d" ]; then
find "$config_base/zsh/conf.d" -name "*.zsh" -type f | sort | while read conf_file; do
local conf_name=$(basename "$conf_file")
local target_file=~/.config/zsh/conf.d/"$conf_name"
if [ -f "$target_file" ]; then
print_color "$YELLOW" " ⚠️ conf.d/$conf_name (already exists)"
else
print_color "$GREEN" " + conf.d/$conf_name (new file)"
fi
done
fi
printf "\n"
fi
else
# Actual installation for Zsh
if [[ -f "$config_base/zsh/.zshrc" ]] || [[ -d "$config_base/zsh/conf.d" ]]; then
log_info "Installing Zsh configuration..."
# Copy main .zshrc
if [ -f "$config_base/zsh/.zshrc" ]; then
local target_file=~/.zshrc
if [ -f "$target_file" ] && [ "$force_overwrite" -eq 0 ]; then
backup_file "$target_file"
fi
cp "$config_base/zsh/.zshrc" "$target_file"
log_success " → .zshrc installed"
fi
# Copy conf.d modules
if [ -d "$config_base/zsh/conf.d" ]; then
mkdir -p ~/.config/zsh/conf.d
find "$config_base/zsh/conf.d" -name "*.zsh" -type f | sort | while read conf_file; do
local conf_name=$(basename "$conf_file")
local target_file=~/.config/zsh/conf.d/"$conf_name"
if [ -f "$target_file" ] && [ "$force_overwrite" -eq 0 ]; then
backup_file "$target_file"
fi
cp "$conf_file" "$target_file"
log_success " → conf.d/$conf_name installed"
done
fi
fi
fi
}
# Install Starship configuration
install_starship_config() {
local config_base="$1"
local force_overwrite="$2"
local dry_run="$3"
if [[ "$dry_run" -eq 1 ]]; then
if [ -f "$config_base/starship/starship.toml" ]; then
print_color "$BOLD" " ⭐ Starship Configuration:"
local target_file=~/.config/starship.toml
if [ -f "$target_file" ]; then
print_color "$YELLOW" " ⚠️ starship.toml (already exists)"
else
print_color "$GREEN" " + starship.toml (new file)"
fi
printf "\n"
fi
else
if [ -f "$config_base/starship/starship.toml" ]; then
log_info "Installing Starship configuration..."
local target_file=~/.config/starship.toml
if [ -f "$target_file" ] && [ "$force_overwrite" -eq 0 ]; then
backup_file "$target_file"
fi
cp "$config_base/starship/starship.toml" "$target_file"
log_success " → starship.toml installed"
fi
fi
}
# Install Ghostty terminal configuration
install_ghostty_config() {
local config_base="$1"
local force_overwrite="$2"
local dry_run="$3"
if [[ "$dry_run" -eq 1 ]]; then
if [ -f "$config_base/ghostty/config" ]; then
print_color "$BOLD" " 👻 Ghostty Configuration:"
local target_dir="$HOME/Library/Application Support/com.mitchellh.ghostty"
local target_file="$target_dir/config"
if [ -f "$target_file" ]; then
print_color "$YELLOW" " ⚠️ ghostty/config (already exists)"
else
print_color "$GREEN" " + ghostty/config (new file)"
fi
printf "\n"
fi
else
if [ -f "$config_base/ghostty/config" ]; then
log_info "Installing Ghostty configuration..."
local target_dir="$HOME/Library/Application Support/com.mitchellh.ghostty"
local target_file="$target_dir/config"
# Create directory if it doesn't exist
mkdir -p "$target_dir"
if [ -f "$target_file" ] && [ "$force_overwrite" -eq 0 ]; then
backup_file "$target_file"
fi
cp "$config_base/ghostty/config" "$target_file"
log_success " → Ghostty config installed"
fi
fi
}
# Main installation function
main() {
local force_overwrite=0
local dry_run=0
# Parse arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--force)
force_overwrite=1
shift
;;
--dry-run)
dry_run=1
shift
;;
-h|--help)
cat <<'USAGE'
Usage: ./install.sh [OPTIONS]
Installs modern shell configuration for Fish, Zsh, and Bash shells with development tools.
Options:
--force Overwrite existing configurations
--dry-run Show what would be done without making changes
-h, --help Show this help message
Configuration is installed to:
- Fish: ~/.config/fish/
- Zsh: ~/.config/zsh/ and ~/.zshrc
- Bash: ~/.config/bash/, ~/.bashrc and ~/.bash_profile
- Starship: ~/.config/starship.toml
USAGE
exit 0
;;
*)
log_error "Unknown option: $1"
exit 2
;;
esac
done
# Show banner
show_banner
# Check dependencies
check_dependencies
log_info "Installing configuration for Fish, Zsh, and Bash shells"
# Detect OS and architecture
local OS=$(uname -s)
local ARCH=$(uname -m)
if [[ "$OS" != "Darwin" ]]; then
log_error "This script is designed for macOS only."
exit 1
fi
log_info "Detected macOS on $ARCH architecture"
printf "\n"
# Detect Homebrew path based on architecture
local BREW_PATH
local FISH_PATH
local ZSH_PATH
if [[ "$ARCH" == "arm64" ]]; then
BREW_PATH="/opt/homebrew/bin/brew"
FISH_PATH="/opt/homebrew/bin/fish"
ZSH_PATH="/opt/homebrew/bin/zsh"
else
BREW_PATH="/usr/local/bin/brew"
FISH_PATH="/usr/local/bin/fish"
ZSH_PATH="/usr/local/bin/zsh"
fi
# Detect source directory
local repo_root
repo_root=$(script_dir)
local config_base="$repo_root/config"
print_color "$BOLD" "=== Installing Homebrew & Development Tools ==="
if [ "$dry_run" -eq 1 ]; then
log_info "[DRY RUN] Would check/install Homebrew at: $BREW_PATH"
log_info "[DRY RUN] Would add Homebrew tap: dorkitude/linctl"
log_info "[DRY RUN] Would install the following tools:"
printf " • neovim - Modern Vim editor\n"
printf " • luarocks - Lua package manager\n"
printf " • tree-sitter - Parser for syntax highlighting\n"
printf " • starship - Cross-shell prompt\n"
printf " • bat - Cat with syntax highlighting\n"
printf " • eza - Modern replacement for ls\n"
printf " • ripgrep - Fast grep alternative\n"
printf " • fd - Fast find alternative\n"
printf " • fzf - Fuzzy finder\n"
printf " • lazygit - Terminal UI for git\n"
printf " • lazydocker - Terminal UI for docker\n"
printf " • fnm - Fast Node.js version manager\n"
printf " • direnv - Per-project environment variables\n"
printf " • zoxide - Smarter cd command (z/zi)\n"
printf " • atuin - Better shell history with sync\n"
printf " • foundry - Ethereum development toolkit\n"
printf " • linctl - Kubernetes cluster management tool\n"
printf " • And more...\n"
printf "\n"
log_info "[DRY RUN] Would install Bun via official installer (curl -fsSL https://bun.sh/install | bash)"
printf "\n"
else
# Install or update Homebrew
log_info "Checking Homebrew installation..."
if ! command -v "$BREW_PATH" &> /dev/null; then
log_warning "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
log_success "Homebrew is already installed"
log_info "Updating Homebrew..."
"$BREW_PATH" update
fi
# Add Homebrew taps
log_info "Adding Homebrew taps..."
"$BREW_PATH" tap dorkitude/linctl || log_warning "Failed to add tap dorkitude/linctl (may already be added)"
# Install modern tools
log_info "Installing modern development tools..."
local TOOLS=(
# Shells
"zsh" # Latest Zsh from Homebrew
"fish" # Fish shell
# Zsh plugins
"zsh-syntax-highlighting"
"zsh-autosuggestions"
"zsh-completions"
# Core tools from shell configs
"starship" # Modern prompt (used in 70-prompt.bash)
"bat" # Better cat (used in 20-fzf.bash for preview)
"eza" # Better ls (used in 10-aliases.bash)
"fd" # Better find (used in 20-fzf.bash)
"ripgrep" # Better grep (rg command)
"fzf" # Fuzzy finder (20-fzf.bash)
"direnv" # Per-project environment variables (60-modern-tools.bash)
"zoxide" # Smarter cd command (60-modern-tools.bash)
"atuin" # Better shell history (60-modern-tools.bash)
"fnm" # Fast Node.js version manager (10-node.bash)
# Additional modern tools
"neovim" # Neovim editor (nvim in aliases)
"lazygit" # Terminal UI for git
"lazydocker" # Terminal UI for docker
"git-delta" # Better git diff
"difftastic" # Better git diff
"chafa" # Terminal graphics
"hexyl" # Hex viewer
"procs" # Better ps
"broot" # Better tree
"luarocks" # Lua package manager for Neovim
"tree-sitter" # Parser generator for Neovim
# Development tools
"foundry" # Ethereum development toolkit
# New tools
"ast-grep" # Structural search/replace tool
"awscli" # AWS Command Line Interface
"azure-cli" # Azure Command Line Interface
"bash" # Latest Bash from Homebrew
"codex" # AI code assistant
"gh" # GitHub CLI
"git" # Latest Git from Homebrew
"helm" # Kubernetes package manager
"helm-docs" # Auto-generate Helm chart documentation
"kubectx" # Switch between kubectl contexts
"kubernetes-cli" # kubectl command
"node" # Node.js JavaScript runtime
"rsync" # Fast file transfer
"tilt" # Local Kubernetes development
"tmux" # Terminal multiplexer
"zellij" # Modern terminal multiplexer
"uv" # Fast Python package installer
"shellcheck" # Shell script static analysis tool
"linctl" # Kubernetes cluster management tool
)
# Install all tools in one go without checking
log_info "Installing all tools in batch (this may take a while)..."
"$BREW_PATH" install "${TOOLS[@]}"
# Install cask applications
log_info "Installing cask applications..."
local CASKS=(
"1password" # Password manager
"chatgpt" # ChatGPT desktop app
"cursor" # AI-powered code editor
"google-cloud-sdk" # Google Cloud SDK (gcloud)
"ghostty" # Modern terminal emulator
"claude" # AI-powered coding assistant
"1password-cli" # 1Password CLI (11-1password.bash)
)
# Get list of installed casks in one go
local installed_casks=$("$BREW_PATH" list --cask 2>/dev/null || true)
# Filter out already installed casks
local casks_to_install=()
for cask in "${CASKS[@]}"; do
if echo "$installed_casks" | grep -q "^${cask}$"; then
log_success "$cask is already installed via Homebrew"
else
casks_to_install+=("$cask")
fi
done
# Install remaining casks in one batch if there are any
if [ ${#casks_to_install[@]} -gt 0 ]; then
log_info "Installing casks in batch: ${casks_to_install[*]}"
"$BREW_PATH" install --cask "${casks_to_install[@]}" || {
log_warning "Some casks failed to install. They may already be installed or require manual installation"
}
else
log_success "All casks are already installed"
fi
# Configure atuin
log_info "Configuring atuin..."
if "$BREW_PATH" services list | grep -q "atuin.*started"; then
log_success "atuin service is already running"
else
# Try to start the service, but don't fail if it doesn't work
if "$BREW_PATH" services start atuin 2>/dev/null; then
log_success "atuin service started"
else
log_warning "Could not start atuin service automatically"
log_info "This is normal on some macOS versions. Atuin will still work in your shell."
fi
fi
# Configure tools that need special setup
log_info "Configuring tool-specific settings..."
# Configure kubectx/kubens
if command -v kubectx &> /dev/null; then
log_info "Configuring kubectx..."
# Create completion directories if they don't exist
mkdir -p ~/.config/fish/completions
mkdir -p ~/.config/zsh/completions
mkdir -p ~/.config/bash/completions
# Link completions for kubectx and kubens
local BREW_PREFIX
if [[ "$ARCH" == "arm64" ]]; then
BREW_PREFIX="/opt/homebrew"
else
BREW_PREFIX="/usr/local"
fi
# Fish completions
if [ -f "$BREW_PREFIX/share/fish/vendor_completions.d/kubectx.fish" ]; then
ln -sf "$BREW_PREFIX/share/fish/vendor_completions.d/kubectx.fish" ~/.config/fish/completions/
ln -sf "$BREW_PREFIX/share/fish/vendor_completions.d/kubens.fish" ~/.config/fish/completions/
fi
# Zsh completions
if [ -f "$BREW_PREFIX/share/zsh/site-functions/_kubectx" ]; then
ln -sf "$BREW_PREFIX/share/zsh/site-functions/_kubectx" ~/.config/zsh/completions/
ln -sf "$BREW_PREFIX/share/zsh/site-functions/_kubens" ~/.config/zsh/completions/
fi
log_success "kubectx/kubens completions configured"
fi
# Configure Google Cloud SDK
if [ -d "/opt/homebrew/Caskroom/google-cloud-sdk" ] || [ -d "/usr/local/Caskroom/google-cloud-sdk" ]; then
log_info "Google Cloud SDK installed - shell integration will be configured via conf.d files"
fi
# Configure Helm
if command -v helm &> /dev/null; then
log_info "Generating Helm completions..."
helm completion bash > ~/.config/bash/completions/helm.bash 2>/dev/null || true
helm completion zsh > ~/.config/zsh/completions/_helm 2>/dev/null || true
helm completion fish > ~/.config/fish/completions/helm.fish 2>/dev/null || true
log_success "Helm completions generated"
fi
# Configure GitHub CLI
if command -v gh &> /dev/null; then
log_info "Generating GitHub CLI completions..."
gh completion -s bash > ~/.config/bash/completions/gh.bash 2>/dev/null || true
gh completion -s zsh > ~/.config/zsh/completions/_gh 2>/dev/null || true
gh completion -s fish > ~/.config/fish/completions/gh.fish 2>/dev/null || true
log_success "GitHub CLI completions generated"
fi
# Install Claude Code CLI
log_info "Installing Claude Code CLI..."
if command -v claude &> /dev/null; then
log_success "Claude Code is already installed"
# Note: claude-code doesn't have an update command built-in
# Users need to reinstall to update
else
log_info "Installing Claude Code via official installer..."
curl -fsSL https://claude.ai/install.sh | bash -s latest
log_success "Claude Code installed successfully"
fi
# Install Bun using official installer
log_info "Installing Bun..."
if command -v bun &> /dev/null; then
log_success "Bun is already installed"
log_info "Updating Bun to latest version..."
bun upgrade
else
log_info "Installing Bun via official installer..."
curl -fsSL https://bun.sh/install | bash
log_success "Bun installed successfully"
fi
fi
printf "\n"
print_color "$BOLD" "=== Configuring Shell ==="
if [ "$dry_run" -eq 1 ]; then
log_info "[DRY RUN] Would add Fish shell to /etc/shells"
log_info "[DRY RUN] Would add Zsh to /etc/shells"
log_info "[DRY RUN] Would create configuration directories"
log_info "[DRY RUN] Would fix Zsh compinit insecure directory permissions"
printf "\n"
else
# Configure Fish
# Add Fish to allowed shells
if grep -q "$FISH_PATH" /etc/shells; then
log_success "Fish shell is already in /etc/shells"
else
log_info "Adding Fish to allowed shells (requires sudo)..."
echo "$FISH_PATH" | sudo tee -a /etc/shells > /dev/null
log_success "Fish shell added to /etc/shells"
fi
# Create Fish config directories
log_info "Creating Fish configuration directories..."
mkdir -p ~/.config/fish/conf.d
# Configure Zsh
# Add Zsh to allowed shells (if custom installation)
if [[ -f "$ZSH_PATH" ]] && ! grep -q "$ZSH_PATH" /etc/shells; then
log_info "Adding Zsh to allowed shells (requires sudo)..."
echo "$ZSH_PATH" | sudo tee -a /etc/shells > /dev/null
log_success "Zsh added to /etc/shells"
fi
# Create Zsh config directories
log_info "Creating Zsh configuration directories..."
mkdir -p ~/.config/zsh/conf.d
# Fix Zsh compinit insecure directories
log_info "Fixing Zsh completion directory permissions..."
# First, fix common Homebrew directories that often have permission issues
# This handles "compinit: insecure directories" errors
if [ -d /opt/homebrew ]; then
# Apple Silicon Mac - fix parent directories first
sudo chown -R $USER /opt/homebrew/share /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions || true
chmod u+w /opt/homebrew/share /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions || true
fi
if [ -d /usr/local/share ]; then
# Intel Mac - fix parent directories first
sudo chown -R $USER /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions || true
chmod u+w /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions || true
fi
# Fix user's Zsh directories
if [ -d ~/.config/zsh ]; then
chmod 755 ~/.config/zsh 2>/dev/null || true
chmod 755 ~/.config/zsh/conf.d 2>/dev/null || true
chmod 755 ~/.config/zsh/completions 2>/dev/null || true
fi
# Now run compaudit to find any remaining insecure directories
if command -v zsh &> /dev/null; then
log_info "Checking for insecure Zsh directories..."
local insecure_dirs
# Run compaudit through zsh to get the list of insecure directories
insecure_dirs=$(zsh -c 'compaudit' 2>/dev/null || true)
if [ -n "$insecure_dirs" ]; then
log_warning "Found insecure directories, fixing permissions..."
echo "$insecure_dirs" | while IFS= read -r dir; do
if [ -n "$dir" ] && [ -d "$dir" ]; then
# Use sudo for system directories, regular chmod for user directories
if [[ "$dir" == /opt/* ]] || [[ "$dir" == /usr/* ]]; then
sudo chown -R $USER "$dir" 2>/dev/null && \
chmod u+w "$dir" 2>/dev/null && \
log_success "Fixed permissions and ownership for: $dir" || log_warning "Could not fix: $dir"
else
sudo chown -R $USER "$dir" 2>/dev/null && log_success "Fixed permissions for: $dir" || log_warning "Could not fix: $dir"
fi
fi
done
# Verify the fix by running compaudit again
local remaining_insecure
remaining_insecure=$(zsh -c 'compaudit' 2>/dev/null || true)
if [ -z "$remaining_insecure" ]; then
log_success "All Zsh directories are now secure"
else
log_warning "Some directories may still need attention. Run 'compaudit' after installation to check."
fi
else
log_success "All Zsh directories are already secure"
fi
fi
# Create Bash config directories
log_info "Creating Bash configuration directories..."
mkdir -p ~/.config/bash/conf.d
# Create Starship directory
mkdir -p ~/.config
fi
printf "\n"
print_color "$BOLD" "=== Configuring Neovim with LazyVim ==="
if [ "$dry_run" -eq 1 ]; then
log_info "[DRY RUN] Would install LazyVim configuration for Neovim"
log_info "[DRY RUN] Would backup existing ~/.config/nvim if present"
log_info "[DRY RUN] Would clone LazyVim starter configuration"
log_info "[DRY RUN] Would download Omarchy configuration files"
log_info "[DRY RUN] Would disable relative line numbers"
printf "\n"
else
log_info "Setting up Neovim with LazyVim..."
# Backup existing Neovim config if present
if [ -d ~/.config/nvim ]; then
local nvim_backup=~/.config/nvim.backup.$(date +%Y%m%d_%H%M%S)
mv ~/.config/nvim "$nvim_backup"
log_info "Backed up existing Neovim config to: $nvim_backup"
fi
# Clone LazyVim starter
log_info "Installing LazyVim starter configuration..."
git clone https://github.com/LazyVim/starter ~/.config/nvim
# Create necessary directories
mkdir -p ~/.config/nvim/lua/plugins
mkdir -p ~/.config/nvim/lua/config
# Create Catppuccin theme configuration
log_info "Configuring Catppuccin theme..."
cat > ~/.config/nvim/lua/plugins/catppuccin.lua << 'EOF'
return {
-- Add Catppuccin colorscheme
{
"catppuccin/nvim",
name = "catppuccin",
priority = 1000,
opts = {
flavour = "macchiato", -- latte, frappe, macchiato, mocha
transparent_background = false,
show_end_of_buffer = false,
term_colors = true,
dim_inactive = {
enabled = false,
shade = "dark",
percentage = 0.15,
},
styles = {
comments = { "italic" },
conditionals = { "italic" },
loops = {},
functions = {},
keywords = {},
strings = {},
variables = {},
numbers = {},
booleans = {},
properties = {},
types = {},
operators = {},
},
integrations = {
cmp = true,
gitsigns = true,
nvimtree = true,
telescope = true,
notify = true,
mini = true,
hop = true,
indent_blankline = {
enabled = true,
colored_indent_levels = false,
},
native_lsp = {
enabled = true,
virtual_text = {
errors = { "italic" },
hints = { "italic" },
warnings = { "italic" },
information = { "italic" },
},
underlines = {
errors = { "underline" },
hints = { "underline" },
warnings = { "underline" },
information = { "underline" },
},
},
},
},
},
-- Configure LazyVim to use Catppuccin
{
"LazyVim/LazyVim",
opts = {
colorscheme = "catppuccin",
},
},
}
EOF
log_success "Catppuccin theme configured"
# Remove the .git directory to make it your own
rm -rf ~/.config/nvim/.git
# Create custom options file with relative numbers disabled
cat > ~/.config/nvim/lua/config/options.lua << 'EOF'
-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here
vim.opt.relativenumber = false
EOF
log_success "Disabled relative line numbers"
log_success "LazyVim installed successfully"
log_info "LazyVim will install plugins on first launch of Neovim"
fi
printf "\n"
print_color "$BOLD" "=== Installing Configuration Files ==="
# Detect if running from local directory or curl
if [[ -n "${BASH_SOURCE[0]:-}" ]] && ([[ -f "$config_base/fish/config.fish" ]] || [[ -f "$config_base/zsh/.zshrc" ]]); then
# Local installation
log_info "Local installation detected"
if [ "$dry_run" -eq 1 ]; then
log_info "[DRY RUN] Would install the following configuration files:"
printf "\n"
fi
# Install configurations for all shells
install_fish_config "$config_base" "$force_overwrite" "$dry_run"
install_zsh_config "$config_base" "$force_overwrite" "$dry_run"
install_bash_config "$config_base" "$force_overwrite" "$dry_run"
# Install Starship for any shell choice
install_starship_config "$config_base" "$force_overwrite" "$dry_run"
# Install Ghostty terminal configuration
install_ghostty_config "$config_base" "$force_overwrite" "$dry_run"
else