Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·1390 lines (1244 loc) · 54.9 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·1390 lines (1244 loc) · 54.9 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
#=================================================================
# DXSBash - Enhanced Shell Environment for Debian and Ubuntu
# Repository: https://github.com/digitalxs/dxsbash
# Author: Luis Miguel P. Freitas
# Website: https://digitalxs.ca
# License: GPL-3.0
#=================================================================
# Strict mode + pipefail so piped failures surface
set -Eeuo pipefail
#=================================================================
# Color definitions for rich terminal output
#=================================================================
RC='\033[0m' # Reset Color
RED='\033[1;31m' # Bold Red
YELLOW='\033[1;33m' # Bold Yellow
GREEN='\033[1;32m' # Bold Green
BLUE='\033[1;34m' # Bold Blue
CYAN='\033[1;36m' # Bold Cyan
WHITE='\033[1;37m' # Bold White
#=================================================================
# Error trap — log the failing line and command
#=================================================================
on_error() {
local ec=$?
echo -e "${RED}✗ setup.sh failed (exit $ec) at line ${BASH_LINENO[0]}: ${BASH_COMMAND}${RC}" >&2
[ -n "${LOG_FILE:-}" ] && echo -e "${YELLOW} See log: $LOG_FILE${RC}" >&2
exit "$ec"
}
trap on_error ERR
#=================================================================
# Who are we running as, and whose HOME should we touch?
#
# If invoked via sudo, SUDO_USER is set to the invoking user and
# $HOME points to /root. We always want the *real* user's home.
#=================================================================
# SUDO_USER only means "the invoking user" when we actually run as root
# (it can linger in the environment, e.g. after sudo -iu <user>)
if [ "$(id -u)" -eq 0 ] && [ -n "${SUDO_USER:-}" ]; then
REAL_USER="$SUDO_USER"
else
REAL_USER="$(id -un)"
fi
USER_HOME="$(getent passwd "$REAL_USER" 2>/dev/null | cut -d: -f6)"
[ -n "$USER_HOME" ] || USER_HOME="${HOME:-/tmp}"
REAL_GROUP="$(id -gn "$REAL_USER" 2>/dev/null || echo "$REAL_USER")"
# Helper: run a command as the real user (strips root if we were sudo'd)
as_user() {
if [ "$(id -u)" -eq 0 ] && [ -n "${SUDO_USER:-}" ]; then
sudo -u "$REAL_USER" -H "$@"
else
"$@"
fi
}
#=================================================================
# Operation mode (install | repair | uninstall)
#
# Can be selected via CLI flag, env var DXSBASH_MODE, or an
# interactive menu when no choice is provided.
#=================================================================
MODE=""
ASSUME_YES=0
NONINTERACTIVE=0
DRY_RUN=0
parse_args() {
while [ $# -gt 0 ]; do
case "$1" in
--install) MODE="install" ;;
--repair) MODE="repair" ;;
--uninstall) MODE="uninstall" ;;
--doctor) MODE="doctor" ;;
-y|--yes) ASSUME_YES=1; NONINTERACTIVE=1 ;;
--dry-run) DRY_RUN=1 ;;
--shell)
shift
case "${1:-}" in
bash|zsh|fish) SELECTED_SHELL="$1" ;;
*) echo "Invalid --shell value: ${1:-}" >&2; exit 2 ;;
esac
;;
-h|--help)
cat <<'USAGE'
DXSBash setup
Usage: setup.sh [MODE] [options]
Modes:
--install Install DXSBash (default when interactive)
--repair Re-link configs, re-install helper commands
--uninstall Remove DXSBash and restore /etc/skel defaults
--doctor Run a health check and report problems (no changes)
Options:
--shell X Choose shell (bash|zsh|fish); overrides menu
-y, --yes Do not prompt; assume yes (non-interactive)
--dry-run Print actions without making changes (install only)
-h, --help Show this help
Environment:
DXSBASH_MODE Same as a mode flag
DXSBASH_SHELL Same as --shell
DXSBASH_SKIP_FONT Set to 1 to skip the Nerd Font download (CI)
USAGE
exit 0
;;
*)
echo "Unknown option: $1" >&2
exit 2
;;
esac
shift
done
if [ -z "$MODE" ] && [ -n "${DXSBASH_MODE:-}" ]; then
MODE="$DXSBASH_MODE"
fi
if [ -z "${SELECTED_SHELL:-}" ] && [ -n "${DXSBASH_SHELL:-}" ]; then
case "$DXSBASH_SHELL" in
bash|zsh|fish) SELECTED_SHELL="$DXSBASH_SHELL" ;;
*) echo "Invalid DXSBASH_SHELL: $DXSBASH_SHELL" >&2; exit 2 ;;
esac
fi
}
#=================================================================
# Display welcome banner
#=================================================================
display_banner() {
echo -e "${BLUE}╔════════════════════════════════════════════════════════╗${RC}"
echo -e "${BLUE}║ ║${RC}"
echo -e "${BLUE}║ ${WHITE}██████╗ ██╗ ██╗███████╗██████╗ █████╗ ███████╗██╗ ██╗${BLUE} ${RC}"
echo -e "${BLUE}║ ${WHITE}██╔══██╗╚██╗██╔╝██╔════╝██╔══██╗██╔══██╗██╔════╝██║ ██║${BLUE} ${RC}"
echo -e "${BLUE}║ ${WHITE}██║ ██║ ╚███╔╝ ███████╗██████╔╝███████║███████╗███████║${BLUE} ${RC}"
echo -e "${BLUE}║ ${WHITE}██║ ██║ ██╔██╗ ╚════██║██╔══██╗██╔══██║╚════██║██╔══██║${BLUE} ${RC}"
echo -e "${BLUE}║ ${WHITE}██████╔╝██╔╝ ██╗███████║██████╔╝██║ ██║███████║██║ ██║${BLUE} ${RC}"
echo -e "${BLUE}║ ${WHITE}╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝${BLUE} ${RC}"
echo -e "${BLUE}║ ║${RC}"
echo -e "${BLUE}║ ${CYAN}Enhanced Shell Environment for Debian & Ubuntu${BLUE} ║${RC}"
echo -e "${BLUE}║ ${YELLOW} $(date +%Y) digitalxs.ca${BLUE} ║${RC}"
echo -e "${BLUE}║ ║${RC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════╝${RC}"
echo ""
}
#=================================================================
# Initialize environment and check prerequisites
#
# Safe when re-run in place: if setup.sh is running *from* the
# target directory, we `git pull` instead of `rm -rf` + clone, which
# would otherwise delete the running script.
#=================================================================
initialize() {
echo -e "${CYAN}▶ Initializing setup...${RC}"
# Ensure .config exists in the *real* user's home
CONFIGDIR="$USER_HOME/.config"
if [ ! -d "$CONFIGDIR" ]; then
echo -e "${YELLOW} Creating .config directory: ${WHITE}$CONFIGDIR${RC}"
as_user mkdir -p "$CONFIGDIR"
echo -e "${GREEN} ✓ .config directory created${RC}"
fi
LINUXTOOLBOXDIR="$USER_HOME/linuxtoolbox"
if [ ! -d "$LINUXTOOLBOXDIR" ]; then
echo -e "${YELLOW} Creating linuxtoolbox directory: ${WHITE}$LINUXTOOLBOXDIR${RC}"
as_user mkdir -p "$LINUXTOOLBOXDIR"
fi
local target="$LINUXTOOLBOXDIR/dxsbash"
local script_dir
script_dir="$(dirname "$(realpath "$0")")"
# Self-wipe guard: don't delete the directory we're running from.
if [ -d "$target" ] && [ "$script_dir" = "$(realpath "$target" 2>/dev/null || echo /nonexistent)" ]; then
echo -e "${YELLOW} Running from $target — pulling updates in place${RC}"
if [ "$DRY_RUN" -eq 0 ]; then
if ( cd "$target" && as_user git pull --ff-only origin main ); then
echo -e "${GREEN} ✓ Repository updated${RC}"
else
echo -e "${YELLOW} ⚠ git pull failed; continuing with current checkout${RC}"
fi
fi
elif [ -d "$target" ]; then
echo -e "${YELLOW} Cleaning existing installation at $target${RC}"
[ "$DRY_RUN" -eq 0 ] && rm -rf "$target"
if [ "$DRY_RUN" -eq 0 ]; then
if ! as_user git clone https://github.com/digitalxs/dxsbash "$target"; then
echo -e "${RED} ✗ Failed to clone repository${RC}"
exit 1
fi
fi
echo -e "${GREEN} ✓ Repository ready${RC}"
else
echo -e "${YELLOW} Cloning DXSBash repository...${RC}"
if [ "$DRY_RUN" -eq 0 ]; then
if ! as_user git clone https://github.com/digitalxs/dxsbash "$target"; then
echo -e "${RED} ✗ Failed to clone repository. Check your internet connection.${RC}"
exit 1
fi
fi
echo -e "${GREEN} ✓ Repository cloned successfully${RC}"
fi
cd "$target" 2>/dev/null || true
# Link everything from the managed clone (the one update-dxsbash
# pulls), never from wherever setup.sh was launched: with the manual
# "git clone … && cd dxsbash && ./setup.sh" install, ~/.bashrc & co.
# used to point into that throwaway checkout and broke when it was
# deleted — and never received updates.
if [ -f "$target/setup.sh" ]; then
GITPATH="$target"
fi
echo -e "${GREEN}▶ Initialization complete${RC}"
echo ""
}
# Main variables that will be used across functions
SUDO_CMD=""
GITPATH=""
SELECTED_SHELL="${SELECTED_SHELL:-}"
# Distro family: debian (incl. Ubuntu), arch, fedora (incl. RHEL-likes),
# or unknown. Set by detectDistro().
DISTRO="unknown"
LOG_FILE=""
# Parse CLI arguments up front
parse_args "$@"
#=================================================================
# Install logging — mirror stdout/stderr to a dated log file under
# ~/.dxsbash/logs/ so post-mortems are possible.
#=================================================================
setup_logging() {
local log_dir="$USER_HOME/.dxsbash/logs"
as_user mkdir -p "$log_dir"
LOG_FILE="$log_dir/install-$(date +%Y%m%d-%H%M%S).log"
as_user touch "$LOG_FILE"
# Tee both streams; keep stderr distinguishable in the log
exec > >(tee -a "$LOG_FILE") 2> >(tee -a "$LOG_FILE" >&2)
echo "=== DXSBash setup started $(date) ===" >> "$LOG_FILE"
echo " args: $*" >> "$LOG_FILE"
echo " user: $REAL_USER ($USER_HOME)" >> "$LOG_FILE"
}
setup_logging "$@"
# Display welcome banner
display_banner
#=================================================================
# Interactive mode selection
#=================================================================
select_mode() {
if [ -n "$MODE" ]; then
return
fi
if [ "$NONINTERACTIVE" -eq 1 ] || [ ! -t 0 ]; then
MODE="install"
return
fi
echo -e "${CYAN}╔════════════════════════════════════════════════════════╗${RC}"
echo -e "${CYAN}║ What would you like to do? ║${RC}"
echo -e "${CYAN}╚════════════════════════════════════════════════════════╝${RC}"
echo -e " ${WHITE}1)${RC} ${GREEN}Install${RC} ${YELLOW}(default — fresh install of DXSBash)${RC}"
echo -e " ${WHITE}2)${RC} ${GREEN}Repair${RC} ${YELLOW}(fix broken symlinks/commands)${RC}"
echo -e " ${WHITE}3)${RC} ${GREEN}Uninstall${RC} ${YELLOW}(remove and restore Debian defaults)${RC}"
echo -e " ${WHITE}4)${RC} ${GREEN}Doctor${RC} ${YELLOW}(check installation health, read-only)${RC}"
echo -e " ${WHITE}5)${RC} Cancel"
echo ""
read -p " Enter your choice [1-5] (default: 1): " mode_choice
case "$mode_choice" in
2) MODE="repair" ;;
3) MODE="uninstall" ;;
4) MODE="doctor" ;;
5) echo -e "${YELLOW}Cancelled.${RC}"; exit 0 ;;
*) MODE="install" ;;
esac
echo ""
}
select_mode
#=================================================================
# Dispatch: repair / uninstall delegate to their dedicated scripts
# living next to this file so setup.sh stays a single entry point.
#=================================================================
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
if [ "$MODE" = "repair" ]; then
REPAIR_ARGS=()
[ "$ASSUME_YES" -eq 1 ] && REPAIR_ARGS+=(--deps)
if [ -x "$SCRIPT_DIR/repair.sh" ]; then
exec "$SCRIPT_DIR/repair.sh" "${REPAIR_ARGS[@]}"
elif [ -x "$USER_HOME/linuxtoolbox/dxsbash/repair.sh" ]; then
exec "$USER_HOME/linuxtoolbox/dxsbash/repair.sh" "${REPAIR_ARGS[@]}"
else
echo -e "${RED}repair.sh not found. Is DXSBash installed?${RC}"
exit 1
fi
fi
if [ "$MODE" = "uninstall" ]; then
UNINSTALL_ARGS=()
[ "$ASSUME_YES" -eq 1 ] && UNINSTALL_ARGS+=(--yes)
if [ -x "$SCRIPT_DIR/uninstall.sh" ]; then
exec "$SCRIPT_DIR/uninstall.sh" "${UNINSTALL_ARGS[@]}"
elif [ -x "$USER_HOME/linuxtoolbox/dxsbash/uninstall.sh" ]; then
exec "$USER_HOME/linuxtoolbox/dxsbash/uninstall.sh" "${UNINSTALL_ARGS[@]}"
else
echo -e "${RED}uninstall.sh not found. Is DXSBash installed?${RC}"
exit 1
fi
fi
if [ "$MODE" = "doctor" ]; then
if [ -x "$SCRIPT_DIR/doctor.sh" ]; then
exec "$SCRIPT_DIR/doctor.sh"
elif [ -x "$USER_HOME/linuxtoolbox/dxsbash/doctor.sh" ]; then
exec "$USER_HOME/linuxtoolbox/dxsbash/doctor.sh"
else
echo -e "${RED}doctor.sh not found. Is DXSBash installed?${RC}"
exit 1
fi
fi
# Default: install — pre-checks, pre-flight and initialize happen
# inside main() at the bottom so all helper functions are defined.
#=================================================================
# Already-installed detection
#
# If all expected symlinks/commands look healthy, suggest repair
# instead of a fresh install — avoids accidental reclone + rechsh.
#=================================================================
is_installed() {
local shell_rc=""
case "$SELECTED_SHELL" in
bash) shell_rc="$USER_HOME/.bashrc" ;;
zsh) shell_rc="$USER_HOME/.zshrc" ;;
fish) shell_rc="$USER_HOME/.config/fish/config.fish" ;;
*) shell_rc="$USER_HOME/.bashrc" ;;
esac
[ -d "$USER_HOME/linuxtoolbox/dxsbash" ] || return 1
[ -L "$shell_rc" ] && readlink "$shell_rc" | grep -q dxsbash || return 1
[ -x /usr/local/bin/update-dxsbash ] || return 1
return 0
}
if [ -z "${SELECTED_SHELL:-}" ] && [ -L "$USER_HOME/.bashrc" ] && \
readlink "$USER_HOME/.bashrc" | grep -q dxsbash; then
DETECTED_INSTALLED_SHELL="bash"
elif [ -L "$USER_HOME/.zshrc" ] && \
readlink "$USER_HOME/.zshrc" | grep -q dxsbash; then
DETECTED_INSTALLED_SHELL="zsh"
elif [ -L "$USER_HOME/.config/fish/config.fish" ] && \
readlink "$USER_HOME/.config/fish/config.fish" | grep -q dxsbash; then
DETECTED_INSTALLED_SHELL="fish"
else
DETECTED_INSTALLED_SHELL=""
fi
if [ -n "$DETECTED_INSTALLED_SHELL" ]; then
echo -e "${YELLOW} DXSBash is already installed (${DETECTED_INSTALLED_SHELL}).${RC}"
if [ "$NONINTERACTIVE" -eq 1 ]; then
echo -e "${YELLOW} --yes set: proceeding with reinstall anyway.${RC}"
echo ""
else
echo -e " ${WHITE}1)${RC} Reinstall (reclones, overwrites)"
echo -e " ${WHITE}2)${RC} Repair ${YELLOW}(recommended)${RC}"
echo -e " ${WHITE}3)${RC} Cancel"
read -p " Choice [1-3] (default: 2): " _existing_choice
case "$_existing_choice" in
1) ;; # fall through to install
3) echo -e "${YELLOW}Cancelled.${RC}"; exit 0 ;;
*)
REPAIR_ARGS=()
if [ -x "$SCRIPT_DIR/repair.sh" ]; then
exec "$SCRIPT_DIR/repair.sh" "${REPAIR_ARGS[@]}"
else
exec "$USER_HOME/linuxtoolbox/dxsbash/repair.sh" "${REPAIR_ARGS[@]}"
fi
;;
esac
echo ""
fi
fi
#=================================================================
# Pre-flight summary (called from main() after shell is chosen)
#=================================================================
show_preflight() {
local shell_label="${SELECTED_SHELL:-bash}"
echo -e "${BLUE}╔════════════════════════════════════════════════════════╗${RC}"
echo -e "${BLUE}║ ${WHITE}Install plan${BLUE} ║${RC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════╝${RC}"
echo -e " ${CYAN}User:${RC} $REAL_USER"
echo -e " ${CYAN}Home:${RC} $USER_HOME"
echo -e " ${CYAN}Shell target:${RC} $shell_label"
echo -e " ${CYAN}Repo dir:${RC} $USER_HOME/linuxtoolbox/dxsbash"
echo -e " ${CYAN}Log file:${RC} $LOG_FILE"
[ "$DRY_RUN" -eq 1 ] && echo -e " ${YELLOW}DRY-RUN: no changes will be made${RC}"
echo ""
echo -e "${CYAN}Will install/link:${RC}"
echo -e " • ~/.${shell_label}rc (or equivalent) → dxsbash repo"
echo -e " • ~/.config/starship.toml, ~/.config/fastfetch/config.jsonc"
echo -e " • /usr/local/bin/{dxsbash,dxsbash-gui,update-dxsbash,dxsbash-config,dxsbash-doctor,"
echo -e " dxsbash-audit,dxsbash-repair,dxsbash-uninstall,reset-shell-profile}"
echo -e " • System packages via apt/nala (requires sudo)"
echo -e " • FiraCode Nerd Font, starship, zoxide, fzf"
echo ""
if [ "$NONINTERACTIVE" -eq 0 ] && [ -t 0 ]; then
read -p " Proceed? (Y/n): " _ok
if [[ "$_ok" =~ ^[Nn]$ ]]; then
echo -e "${YELLOW}Aborted.${RC}"
exit 0
fi
echo ""
fi
}
#=================================================================
# Utility functions
#=================================================================
command_exists() {
command -v "$1" >/dev/null 2>&1
}
#=================================================================
# Environment checking
#=================================================================
# Which desktop is installed (kde | xfce | other | empty), using the
# shared detection in settings-lib.sh — in a subshell so the library's
# globals stay out of setup's environment. KDE Plasma and XFCE are found
# even when setup runs over SSH or from a text console.
desktop_kind() {
local lib="${GITPATH:-$(dirname "$(realpath "$0")")}/settings-lib.sh"
[ -f "$lib" ] || return 0
bash -c 'source "$1" && detect_desktop' _ "$lib" 2>/dev/null
}
# Install the settings GUI (zenity, menu entry, update notifications)?
# Headless servers get none of it (no GTK stack pulled in). Override
# with DXSBASH_DESKTOP=1 or =0.
has_desktop() {
case "${DXSBASH_DESKTOP:-auto}" in
1|yes|true) return 0 ;;
0|no|false) return 1 ;;
esac
[ -n "$(desktop_kind)" ]
}
checkEnv() {
echo -e "${CYAN}▶ Checking environment requirements...${RC}"
## Check for required tools
REQUIREMENTS='curl sudo git'
for req in $REQUIREMENTS; do
if ! command_exists "$req"; then
echo -e "${RED} ✗ Required tool missing: ${WHITE}$req${RC}"
echo -e "${YELLOW} Please install the following requirements and try again: ${WHITE}$REQUIREMENTS${RC}"
exit 1
fi
done
echo -e "${GREEN} ✓ All required tools are installed${RC}"
## Check for privilege escalation tool
if command_exists sudo; then
SUDO_CMD="sudo"
else
echo -e "${RED} ✗ sudo is required for this installation${RC}"
exit 1
fi
echo -e "${GREEN} ✓ Using ${WHITE}$SUDO_CMD${GREEN} for privilege escalation${RC}"
## Check if the current directory is writable
GITPATH=$(dirname "$(realpath "$0")")
if [ ! -w "$GITPATH" ]; then
echo -e "${RED} ✗ Cannot write to directory: ${WHITE}$GITPATH${RC}"
exit 1
fi
## Ensure user can escalate privileges: root passes outright (root is
## not in the sudo group, so the old group check wrongly rejected
## 'sudo ./setup.sh'); otherwise accept sudo/wheel/admin membership.
if [ "$(id -u)" -ne 0 ] && ! groups | grep -qwE "sudo|wheel|admin"; then
echo -e "${RED} ✗ You need to be a member of the ${WHITE}sudo${RED} (or wheel) group to run this script!${RC}"
exit 1
fi
echo -e "${GREEN}▶ Environment check passed${RC}"
echo ""
}
#=================================================================
# Distribution detection
#=================================================================
detectDistro() {
echo -e "${CYAN}▶ Detecting Linux distribution...${RC}"
# Family-level detection from os-release: ID first, then ID_LIKE so
# derivatives (Mint, Manjaro, Rocky, ...) map to their parent family.
# Same logic the shell rc files use at runtime.
local os_id="" os_like="" os_name=""
if [ -r /etc/os-release ]; then
os_id=$(. /etc/os-release && echo "${ID:-}")
os_like=$(. /etc/os-release && echo "${ID_LIKE:-}")
os_name=$(. /etc/os-release && echo "${PRETTY_NAME:-${ID:-}}")
fi
case "$os_id" in
debian|ubuntu) DISTRO="debian" ;;
arch|manjaro|endeavouros) DISTRO="arch" ;;
fedora|rhel|centos|rocky|almalinux) DISTRO="fedora" ;;
*)
case " $os_like " in
*debian*|*ubuntu*) DISTRO="debian" ;;
*arch*) DISTRO="arch" ;;
*fedora*|*rhel*) DISTRO="fedora" ;;
esac
;;
esac
# Minimal chroots may lack os-release; the marker file still works.
if [ "$DISTRO" = "unknown" ] && [ -f /etc/debian_version ]; then
DISTRO="debian"
os_name="Debian $(cat /etc/debian_version)"
fi
case "$DISTRO" in
debian) echo -e "${GREEN} ✓ Detected ${WHITE}${os_name:-Debian/Ubuntu}${GREEN} — using apt${RC}" ;;
arch) echo -e "${GREEN} ✓ Detected ${WHITE}${os_name:-Arch Linux}${GREEN} — using pacman${RC}" ;;
fedora) echo -e "${GREEN} ✓ Detected ${WHITE}${os_name:-Fedora}${GREEN} — using dnf${RC}" ;;
*)
echo -e "${RED} ⚠ Warning: DXSBash supports Debian, Ubuntu, Arch Linux and Fedora.${RC}"
echo -e "${YELLOW} Your system appears to be running a different distribution.${RC}"
echo -e "${YELLOW} Some features may not work as expected.${RC}"
echo ""
if [ "$NONINTERACTIVE" -eq 1 ]; then
echo -e "${YELLOW} Continuing anyway (--yes)${RC}"
else
read -p " Do you want to continue anyway? (y/N): " continue_install
if [[ ! "$continue_install" =~ ^[Yy]$ ]]; then
echo -e "${RED} Installation aborted.${RC}"
exit 1
fi
fi
;;
esac
echo ""
}
#=================================================================
# Dependency installation
#=================================================================
installDepend() {
echo -e "${CYAN}▶ Installing dependencies...${RC}"
## Check for dependencies.
COMMON_DEPENDENCIES='bash tar bat tree multitail curl wget unzip fontconfig joe git nano zoxide fzf pwgen ripgrep fastfetch'
# Shell-specific dependencies
BASH_DEPENDENCIES="bash bash-completion btop"
ZSH_DEPENDENCIES="zsh zsh-autosuggestions zsh-syntax-highlighting"
FISH_DEPENDENCIES="fish"
# Combine dependencies based on the selected shell.
# nala is a Debian/Ubuntu apt frontend and only exists there.
DEPENDENCIES="$COMMON_DEPENDENCIES plocate trash-cli powerline"
if [ "$DISTRO" = "debian" ]; then
DEPENDENCIES="$DEPENDENCIES nala"
fi
# Add shell-specific dependencies
if [ "$SELECTED_SHELL" = "bash" ]; then
DEPENDENCIES="$DEPENDENCIES $BASH_DEPENDENCIES"
elif [ "$SELECTED_SHELL" = "zsh" ]; then
DEPENDENCIES="$DEPENDENCIES $ZSH_DEPENDENCIES"
elif [ "$SELECTED_SHELL" = "fish" ]; then
DEPENDENCIES="$DEPENDENCIES $FISH_DEPENDENCIES"
fi
if ! command_exists nvim; then
DEPENDENCIES="${DEPENDENCIES} neovim"
fi
# Graphical settings (dxsbash-gui) — desktops only
if has_desktop; then
DEPENDENCIES="${DEPENDENCIES} zenity"
fi
echo -e "${YELLOW} Installing required packages: ${WHITE}$DEPENDENCIES${RC}"
if [ "$DISTRO" = "debian" ]; then
# First check if nala is installed; fall back to apt if it can't be.
# 'update' failures are tolerated: unrelated third-party repos with
# broken metadata (dead PPAs, changed labels, expired keys) are
# common on real systems and must not abort the install — package
# installation still works from the existing lists.
if ! command_exists nala; then
echo -e "${YELLOW} Installing nala package manager...${RC}"
${SUDO_CMD} apt update || \
echo -e "${YELLOW} ⚠ apt update reported errors; continuing with existing package lists${RC}"
${SUDO_CMD} apt install -y nala || \
echo -e "${YELLOW} ⚠ Could not install nala; falling back to apt${RC}"
fi
# Prefer nala only when it actually works: a broken python-apt
# (e.g. after installing a non-default python3) leaves the nala
# binary present but unusable.
local pkg_mgr="apt"
if command_exists nala && nala --version >/dev/null 2>&1; then
pkg_mgr="nala"
fi
${SUDO_CMD} "$pkg_mgr" update || \
echo -e "${YELLOW} ⚠ ${pkg_mgr} update reported errors; continuing with existing package lists${RC}"
# Filter out packages that don't exist on this release (for example
# fastfetch on Debian 12 / Ubuntu 24.04) so one missing package
# doesn't abort the whole install under 'set -e'.
local available_pkgs="" unavailable_pkgs=""
local pkg
for pkg in $DEPENDENCIES; do
if apt-cache show "$pkg" >/dev/null 2>&1; then
available_pkgs="$available_pkgs $pkg"
else
unavailable_pkgs="$unavailable_pkgs $pkg"
fi
done
if [ -n "$unavailable_pkgs" ]; then
echo -e "${YELLOW} ⚠ Not available on this release (skipped):${WHITE}$unavailable_pkgs${RC}"
fi
# shellcheck disable=SC2086 # word splitting of the package list is intended
if ! ${SUDO_CMD} "$pkg_mgr" install -y $available_pkgs; then
if [ "$pkg_mgr" = "nala" ]; then
echo -e "${YELLOW} ⚠ nala install failed; retrying with apt${RC}"
# shellcheck disable=SC2086
${SUDO_CMD} apt install -y $available_pkgs
else
echo -e "${RED} ✗ Package installation failed${RC}"
exit 1
fi
fi
elif [ "$DISTRO" = "arch" ]; then
# Refresh the sync database, then filter out packages this system's
# repos don't carry so one miss doesn't abort the transaction.
${SUDO_CMD} pacman -Sy --noconfirm || \
echo -e "${YELLOW} ⚠ pacman -Sy reported errors; continuing with existing sync db${RC}"
local available_pkgs="" unavailable_pkgs=""
local pkg
for pkg in $DEPENDENCIES; do
if pacman -Si "$pkg" >/dev/null 2>&1; then
available_pkgs="$available_pkgs $pkg"
else
unavailable_pkgs="$unavailable_pkgs $pkg"
fi
done
if [ -n "$unavailable_pkgs" ]; then
echo -e "${YELLOW} ⚠ Not in the configured repos (skipped):${WHITE}$unavailable_pkgs${RC}"
fi
# -Su alongside the install list: installing new packages against a
# stale system is a partial upgrade, which Arch does not support —
# one transaction that upgrades and installs avoids broken libs.
# shellcheck disable=SC2086 # word splitting of the package list is intended
if ! ${SUDO_CMD} pacman -Su --needed --noconfirm $available_pkgs; then
echo -e "${RED} ✗ Package installation failed${RC}"
exit 1
fi
elif [ "$DISTRO" = "fedora" ]; then
# Same availability filter for dnf (RHEL-likes may lack e.g.
# fastfetch or powerline without EPEL).
local available_pkgs="" unavailable_pkgs=""
local pkg
for pkg in $DEPENDENCIES; do
if dnf info -q "$pkg" >/dev/null 2>&1; then
available_pkgs="$available_pkgs $pkg"
else
unavailable_pkgs="$unavailable_pkgs $pkg"
fi
done
if [ -n "$unavailable_pkgs" ]; then
echo -e "${YELLOW} ⚠ Not in the configured repos (skipped):${WHITE}$unavailable_pkgs${RC}"
fi
# shellcheck disable=SC2086 # word splitting of the package list is intended
if ! ${SUDO_CMD} dnf install -y $available_pkgs; then
echo -e "${RED} ✗ Package installation failed${RC}"
exit 1
fi
else
# Unknown distro: fall back to apt if available, otherwise ask the
# user to install manually.
if command_exists apt; then
${SUDO_CMD} apt update
${SUDO_CMD} apt install -y $DEPENDENCIES
else
echo -e "${RED} ✗ Unable to find a supported package manager.${RC}"
echo -e "${YELLOW} Please install the following packages manually: ${WHITE}$DEPENDENCIES${RC}"
read -p " Press Enter to continue..."
fi
fi
echo -e "${GREEN} ✓ Dependencies installed successfully${RC}"
# Install FiraCode Nerd Font if missing.
# Set DXSBASH_SKIP_FONT=1 to skip the ~30 MB download (useful in CI).
FONT_NAME="FiraCode Nerd Font"
if [ "${DXSBASH_SKIP_FONT:-0}" = "1" ]; then
echo -e "${YELLOW} Skipping font installation (DXSBASH_SKIP_FONT=1)${RC}"
elif fc-list | grep -q "FiraCode"; then
echo -e "${GREEN} ✓ Font '$FONT_NAME' is already installed${RC}"
else
echo -e "${YELLOW} Installing font '$FONT_NAME'...${RC}"
local FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/download/v3.3.0/FiraCode.zip"
local FONT_DIR="$USER_HOME/.local/share/fonts"
if wget -q --spider "$FONT_URL"; then
local TEMP_DIR
TEMP_DIR=$(mktemp -d)
if wget -q --show-progress "$FONT_URL" -O "$TEMP_DIR/FiraCode.zip"; then
if unzip -q "$TEMP_DIR/FiraCode.zip" -d "$TEMP_DIR"; then
as_user mkdir -p "$FONT_DIR/FiraCode"
# Support both flat-zip (v3.x) and nested layouts
find "$TEMP_DIR" -type f -name '*.ttf' -exec mv {} "$FONT_DIR/FiraCode/" \; 2>/dev/null || true
if [ "$(id -u)" -eq 0 ]; then
chown -R "$REAL_USER:$REAL_GROUP" "$FONT_DIR/FiraCode" 2>/dev/null || true
fi
as_user fc-cache -f "$FONT_DIR" >/dev/null 2>&1 || true
echo -e "${GREEN} ✓ Font '$FONT_NAME' installed successfully${RC}"
else
echo -e "${YELLOW} ⚠ Failed to unzip font; continuing without it${RC}"
fi
else
echo -e "${YELLOW} ⚠ Font download failed; continuing without it${RC}"
fi
rm -rf "$TEMP_DIR"
else
echo -e "${YELLOW} ⚠ Font URL not accessible; continuing without font${RC}"
fi
fi
echo -e "${GREEN}▶ All dependencies installed${RC}"
echo ""
}
#=================================================================
# Additional tools installation
#=================================================================
installStarshipAndFzf() {
echo -e "${CYAN}▶ Installing Starship prompt...${RC}"
if command_exists starship; then
echo -e "${GREEN} ✓ Starship already installed${RC}"
else
echo -e "${YELLOW} Installing Starship prompt...${RC}"
# Pass -y when running unattended: the installer's confirmation
# prompt cannot be answered without a terminal.
local starship_yes=""
if [ "$NONINTERACTIVE" -eq 1 ] || [ ! -t 0 ]; then
starship_yes="-y"
fi
if curl -sS https://starship.rs/install.sh | sh -s -- ${starship_yes}; then
echo -e "${GREEN} ✓ Starship installed successfully${RC}"
else
echo -e "${RED} ✗ Something went wrong during Starship installation!${RC}"
echo -e "${YELLOW} Continuing without Starship...${RC}"
fi
fi
echo -e "${CYAN}▶ Installing FZF...${RC}"
if command_exists fzf; then
echo -e "${GREEN} ✓ FZF already installed${RC}"
else
echo -e "${YELLOW} Installing FZF...${RC}"
if [ -d "$USER_HOME/.fzf" ]; then
echo -e "${YELLOW} ~/.fzf already exists; skipping clone${RC}"
else
as_user git clone --depth 1 https://github.com/junegunn/fzf.git "$USER_HOME/.fzf"
fi
as_user "$USER_HOME/.fzf/install" --all --no-update-rc >/dev/null || \
echo -e "${YELLOW} ⚠ fzf installer returned non-zero; continuing${RC}"
echo -e "${GREEN} ✓ FZF installed successfully${RC}"
fi
echo ""
}
installZoxide() {
echo -e "${CYAN}▶ Installing Zoxide...${RC}"
if command_exists zoxide; then
echo -e "${GREEN} ✓ Zoxide already installed${RC}"
return
fi
echo -e "${YELLOW} Installing Zoxide...${RC}"
if curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh; then
echo -e "${GREEN} ✓ Zoxide installed successfully${RC}"
else
echo -e "${RED} ✗ Something went wrong during Zoxide installation!${RC}"
echo -e "${YELLOW} Continuing without Zoxide...${RC}"
fi
echo ""
}
#=================================================================
# Shell selection
#
# Honours (in order): --shell flag, DXSBASH_SHELL env var, interactive
# prompt. Non-interactive runs without a shell choice default to bash.
#=================================================================
selectShell() {
# Already chosen via --shell or DXSBASH_SHELL
if [ -n "$SELECTED_SHELL" ]; then
echo -e "${GREEN} ✓ Using shell: ${WHITE}$SELECTED_SHELL${RC}"
echo ""
return
fi
if [ "$NONINTERACTIVE" -eq 1 ] || [ ! -t 0 ]; then
SELECTED_SHELL="bash"
echo -e "${GREEN} ✓ Non-interactive: defaulting to ${WHITE}bash${RC}"
echo ""
return
fi
echo -e "${CYAN}╔════════════════════════════════════════════════════════╗${RC}"
echo -e "${CYAN}║ Select your preferred shell: ║${RC}"
echo -e "${CYAN}╚════════════════════════════════════════════════════════╝${RC}"
echo -e " ${WHITE}1)${RC} ${GREEN}Bash${RC} ${YELLOW}(default, most compatible)${RC}"
echo -e " ${WHITE}2)${RC} ${GREEN}Zsh${RC} ${YELLOW}(enhanced features, popular alternative)${RC}"
echo -e " ${WHITE}3)${RC} ${GREEN}Fish${RC} ${YELLOW}(modern, user-friendly, less POSIX-compatible)${RC}"
echo ""
read -p " Enter your choice [1-3] (default: 1): " shell_choice
case "$shell_choice" in
2) SELECTED_SHELL="zsh" ;;
3) SELECTED_SHELL="fish" ;;
*) SELECTED_SHELL="bash" ;;
esac
echo -e "${GREEN} ✓ Selected shell: ${WHITE}$SELECTED_SHELL${RC}"
echo ""
}
#=================================================================
# Configuration setup
#=================================================================
create_fastfetch_config() {
echo -e "${CYAN}▶ Setting up fastfetch configuration...${RC}"
if [ ! -d "$USER_HOME/.config/fastfetch" ]; then
as_user mkdir -p "$USER_HOME/.config/fastfetch"
fi
# Check if the fastfetch config file exists
if [ -e "$USER_HOME/.config/fastfetch/config.jsonc" ]; then
rm -f "$USER_HOME/.config/fastfetch/config.jsonc"
fi
ln -svf "$GITPATH/config.jsonc" "$USER_HOME/.config/fastfetch/config.jsonc" || {
echo -e "${RED} ✗ Failed to create symbolic link for fastfetch config${RC}"
echo -e "${YELLOW} Using direct copy instead...${RC}"
cp -f "$GITPATH/config.jsonc" "$USER_HOME/.config/fastfetch/config.jsonc"
}
echo -e "${GREEN} ✓ Fastfetch configuration set up successfully${RC}"
echo ""
}
setupShellConfig() {
echo -e "${CYAN}▶ Setting up shell configuration for ${WHITE}$SELECTED_SHELL${CYAN}...${RC}"
# Make sure all required directories exist (owned by the real user)
as_user mkdir -p "$USER_HOME/.config/fish"
as_user mkdir -p "$USER_HOME/.zsh"
# Backup existing config files and set up new ones based on selected shell
if [ "$SELECTED_SHELL" = "bash" ]; then
if [ -e "$USER_HOME/.bashrc" ]; then
BACKUP_FILE="$USER_HOME/.bashrc.bak.$(date +%Y%m%d%H%M%S)"
echo -e "${YELLOW} Backing up old bash config to ${WHITE}$BACKUP_FILE${RC}"
cp -f "$USER_HOME/.bashrc" "$BACKUP_FILE"
fi
# Link Bash config
echo -e "${YELLOW} Creating bash configuration links...${RC}"
ln -svf "$GITPATH/.bashrc" "$USER_HOME/.bashrc" || {
echo -e "${YELLOW} Using direct copy for .bashrc...${RC}"
cp -f "$GITPATH/.bashrc" "$USER_HOME/.bashrc"
}
ln -svf "$GITPATH/.bashrc_help" "$USER_HOME/.bashrc_help" || {
echo -e "${YELLOW} Using direct copy for .bashrc_help...${RC}"
cp -f "$GITPATH/.bashrc_help" "$USER_HOME/.bashrc_help"
}
# Link Bash aliases file
if [ -f "$GITPATH/.bash_aliases" ]; then
ln -svf "$GITPATH/.bash_aliases" "$USER_HOME/.bash_aliases" || {
echo -e "${YELLOW} Using direct copy for .bash_aliases...${RC}"
cp -f "$GITPATH/.bash_aliases" "$USER_HOME/.bash_aliases"
}
echo -e "${GREEN} ✓ Added .bash_aliases file${RC}"
else
# Create a minimal .bash_aliases file if it doesn't exist in the repository
echo "# Custom user aliases - Created by dxsbash setup" > "$USER_HOME/.bash_aliases"
echo "# Add your personal aliases below" >> "$USER_HOME/.bash_aliases"
echo "" >> "$USER_HOME/.bash_aliases"
echo -e "${GREEN} ✓ Created basic .bash_aliases file${RC}"
fi
echo -e "${GREEN} ✓ Bash configuration completed${RC}"
elif [ "$SELECTED_SHELL" = "zsh" ]; then
# Check if .zshrc exists and handle accordingly
if [ -e "$USER_HOME/.zshrc" ]; then
# Backup existing .zshrc
BACKUP_FILE="$USER_HOME/.zshrc.bak.$(date +%Y%m%d%H%M%S)"
echo -e "${YELLOW} Backing up old zsh config to ${WHITE}$BACKUP_FILE${RC}"
cp -f "$USER_HOME/.zshrc" "$BACKUP_FILE"
fi
# Link Zsh config
echo -e "${YELLOW} Installing dxsbash Zsh configuration...${RC}"
ln -svf "$GITPATH/.zshrc" "$USER_HOME/.zshrc" || {
echo -e "${YELLOW} Using direct copy for .zshrc...${RC}"
cp -f "$GITPATH/.zshrc" "$USER_HOME/.zshrc"
}
ln -svf "$GITPATH/.zshrc_help" "$USER_HOME/.zshrc_help" || {
echo -e "${YELLOW} Using direct copy for .zshrc_help...${RC}"
cp -f "$GITPATH/.zshrc_help" "$USER_HOME/.zshrc_help"
}
# Install Oh My Zsh if not already installed.
# KEEP_ZSHRC=yes is essential: without it the installer moves the
# dxsbash ~/.zshrc symlink aside and replaces it with its own
# template, so fresh zsh installs would boot with stock OMZ.
if [ ! -d "$USER_HOME/.oh-my-zsh" ]; then
echo -e "${YELLOW} Installing Oh My Zsh...${RC}"
KEEP_ZSHRC=yes sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
echo -e "${GREEN} ✓ Oh My Zsh installed${RC}"
else
echo -e "${GREEN} ✓ Oh My Zsh already installed${RC}"
fi
echo -e "${GREEN} ✓ Zsh configuration completed${RC}"
elif [ "$SELECTED_SHELL" = "fish" ]; then
if [ -e "$USER_HOME/.config/fish/config.fish" ]; then
BACKUP_DIR="$USER_HOME/.config/fish/backup"
mkdir -p "$BACKUP_DIR"
BACKUP_FILE="$BACKUP_DIR/config.fish.$(date +%Y%m%d%H%M%S)"
echo -e "${YELLOW} Backing up old fish config to ${WHITE}$BACKUP_FILE${RC}"
cp -f "$USER_HOME/.config/fish/config.fish" "$BACKUP_FILE"
fi
# Link Fish config
echo -e "${YELLOW} Installing dxsbash Fish configuration...${RC}"
ln -svf "$GITPATH/config.fish" "$USER_HOME/.config/fish/config.fish" || {
echo -e "${YELLOW} Using direct copy for config.fish...${RC}"
cp -f "$GITPATH/config.fish" "$USER_HOME/.config/fish/config.fish"
}
# Create help file for fish
ln -svf "$GITPATH/fish_help" "$USER_HOME/.config/fish/fish_help" || {
echo -e "${YELLOW} Using direct copy for fish_help...${RC}"
cp -f "$GITPATH/fish_help" "$USER_HOME/.config/fish/fish_help"
}
# Setup Fisher plugin manager if not already installed.
# NOTE: the old https://git.io/fisher redirect was shut down by
# GitHub in 2022; install directly from the canonical location.
if ! fish -c "type -q fisher" 2>/dev/null; then
echo -e "${YELLOW} Installing Fisher plugin manager for Fish...${RC}"
local FISHER_URL="https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish"
if fish -c "curl -sSfL $FISHER_URL | source && fisher install jorgebucaran/fisher"; then
echo -e "${GREEN} ✓ Fisher installed${RC}"
echo -e "${YELLOW} Installing Fish plugins...${RC}"
fish -c "fisher install PatrickF1/fzf.fish" || \
echo -e "${YELLOW} ⚠ Could not install fzf.fish${RC}"
fish -c "fisher install jethrokuan/z" || \
echo -e "${YELLOW} ⚠ Could not install jethrokuan/z${RC}"
fish -c "fisher install IlanCosman/tide@v5" || \
echo -e "${YELLOW} ⚠ Could not install tide${RC}"
echo -e "${GREEN} ✓ Fish plugins installed${RC}"
else
echo -e "${YELLOW} ⚠ Fisher install failed; continuing without plugins${RC}"
fi
else
echo -e "${GREEN} ✓ Fisher already installed${RC}"
fi
echo -e "${GREEN} ✓ Fish configuration completed${RC}"
fi
# Link starship.toml for all shells
echo -e "${YELLOW} Setting up Starship prompt configuration...${RC}"
ln -svf "$GITPATH/starship.toml" "$USER_HOME/.config/starship.toml" || {
echo -e "${YELLOW} Using direct copy for starship.toml...${RC}"
cp -f "$GITPATH/starship.toml" "$USER_HOME/.config/starship.toml"