Repository navigation
Expand file tree
/
Copy pathrun.fish
More file actions
executable file
·79 lines (64 loc) · 2.28 KB
/
Copy pathrun.fish
File metadata and controls
executable file
·79 lines (64 loc) · 2.28 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
#!/usr/bin/env fish
# determine system operating system
set -l UNAME (uname -a)
# uname only names cachyos through the kernel suffix, which a stock arch kernel
# would drop, so linux distros are read from os-release instead
set -l OS_RELEASE_ID
if test -f /etc/os-release
set OS_RELEASE_ID (string replace -rf '^ID=' '' < /etc/os-release | string trim -c '"')
end
switch "$OS_RELEASE_ID $UNAME"
case "cachyos *"
set -gx SYSTEM_OS cachyos
case "*Darwin*"
set -gx SYSTEM_OS darwin
case "*Ubuntu*"
set -gx SYSTEM_OS ubuntu
case "*"
echo "Unsupported OS, uname reports: $UNAME" >&2
echo "Supported: CachyOS, macOS (Darwin), Ubuntu" >&2
exit 1
end
# set global dotfiles paths
set -gx DOTFILES_DIRECTORY (pwd)
set -gx DOTFILES_OS_DISTRO_DIRECTORY $DOTFILES_DIRECTORY/os/$SYSTEM_OS
set -gx DOTFILES_OS_COMMON_DIRECTORY $DOTFILES_DIRECTORY/os/common
# set global home paths
set -gx HOME_CONFIG_DIRECTORY $HOME/.config
set -gx HOME_FISH_DIRECTORY $HOME_CONFIG_DIRECTORY/fish
# bun falls back to $XDG_CACHE_HOME/.bun for global installs when BUN_INSTALL is
# unset, which is not the path config.fish adds, so anything installed during a
# run ends up unreachable and gets reinstalled next run. Pin it to the value
# config.fish uses
set -gx BUN_INSTALL $HOME/.bun
# parse flags
argparse l/launcher r/reboot u/update -- $argv
or return
# set run reboot flag
if set -q _flag_reboot
set -gx RUN_DOTFILES_REBOOT true
end
# set run update flag
if set -q _flag_update
set -gx RUN_DOTFILES_UPDATE true
end
# source fish functions
# include fish/functions so the shared helpers (messaging, configure-user, …) load
# on a fresh machine, before ~/.config/fish/functions has been symlinked
set -l OS_PATHS $DOTFILES_DIRECTORY/fish/functions $DOTFILES_OS_DISTRO_DIRECTORY $DOTFILES_OS_DISTRO_DIRECTORY/**/ $DOTFILES_OS_COMMON_DIRECTORY $DOTFILES_OS_COMMON_DIRECTORY/**/
for dir in $OS_PATHS
if test -d $dir
if not contains $dir $fish_function_path
set -gp fish_function_path $dir
end
end
end
run-$SYSTEM_OS-pre
run-common-pre
header-message "welcome to the dot-launcher for fish shell"
if set -q _flag_launcher
dot-launcher
else
run-$SYSTEM_OS-all
end
header-message "thank you for using the dot-launcher for fish shell"