-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·212 lines (185 loc) · 9.49 KB
/
install.sh
File metadata and controls
executable file
·212 lines (185 loc) · 9.49 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
#!/usr/bin/env bash
set -euo pipefail
DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$DOTFILES_DIR"
TERM_PACKAGES=(fish nvim yazi zellij scripts)
DESKTOP_PACKAGES=(desktop)
ALL_PACKAGES=("${TERM_PACKAGES[@]}" "${DESKTOP_PACKAGES[@]}")
# --- Logging ---
info() { printf '\033[1;34m::\033[0m %s\n' "$*"; }
success() { printf '\033[1;32m::\033[0m %s\n' "$*"; }
error() { printf '\033[1;31m::\033[0m %s\n' "$*" >&2; }
header() { printf '\n\033[1;35m>>> %s\033[0m\n' "$*"; }
require() {
for cmd in "$@"; do
command -v "$cmd" &>/dev/null || { error "Required command not found: $cmd"; exit 1; }
done
}
# --- Core operations ---
link_packages() {
header "Linking packages: $*"
stow --restow --verbose=1 --target "$HOME" --dir "$DOTFILES_DIR" "$@"
}
unlink_packages() {
header "Unlinking packages: $*"
stow -D --verbose=1 --target "$HOME" --dir "$DOTFILES_DIR" "$@"
}
# --- Plugin installers ---
install_yazi_plugins() {
header "Installing yazi plugins"
ya pkg install
}
install_fish_plugins() {
header "Installing fish plugins (Fisher)"
fish -c "curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher update"
# https://github.com/IlanCosman/tide/wiki/Syncing-your-tide-config-in-your-dotfiles
fish -c "tide configure --auto --style=Lean --prompt_colors='True color' --show_time=No --lean_prompt_height='Two lines' --prompt_connection=Disconnected --prompt_spacing=Sparse --icons='Few icons' --transient=No"
}
# --- Commands ---
cmd_install() {
local scope="${1:-all}"
local term_bin_names=(stow fish yazi nvim)
local desktop_bin_names=(stow alacritty dunst hyprland rofi sway waybar)
case "$scope" in
term)
require "${term_bin_names[@]}"
link_packages "${TERM_PACKAGES[@]}"
install_fish_plugins
install_yazi_plugins
;;
desktop)
require "${desktop_bin_names[@]}"
link_packages "${DESKTOP_PACKAGES[@]}"
;;
all)
require "${term_bin_names[@]}" "${desktop_bin_names[@]}"
link_packages "${ALL_PACKAGES[@]}"
install_fish_plugins
install_yazi_plugins
;;
*) error "Unknown scope: $scope (use term, desktop, or all)"; exit 1 ;;
esac
success "Install complete"
echo
show_banner
}
cmd_update() {
if command -v fish &>/dev/null && [[ -f "$HOME/.config/fish/fish_plugins" ]]; then
header "Updating fish plugins"
fish -c "fisher update"
header "Generating fish completions from man pages"
fish -c "fish_update_completions"
fi
if [[ -d "$HOME/.config/nvim" ]]; then
header "Updating neovim plugins"
nvim --headless -c 'lua vim.pack.update(nil, { force = true })' -c 'sleep 10' -c 'qa!'
fi
if command -v ya &>/dev/null; then
header "Updating yazi plugins"
ya pkg upgrade
fi
success "Update complete"
}
cmd_unlink() {
unlink_packages "${ALL_PACKAGES[@]}"
success "All packages unlinked"
}
cmd_health() {
local ok=$'\033[1;32m✓\033[0m' fail=$'\033[1;31m✗\033[0m' warn=$'\033[1;33m!\033[0m'
check() {
if command -v "$1" >/dev/null 2>&1; then
version=$({ "$1" --version 2>/dev/null || "$1" -V 2>/dev/null; } | head -n 1)
printf " $ok %-12s %s\n" "$1" "$version"
else
printf " $fail %-12s not found\n" "$1"
fi
}
header "Required tools"
for cmd in fish nvim yazi zellij stow git fzf rg eza; do check "$cmd"; done
header "Environment"
[[ "$TERM" == *256color* || "$TERM" == *alacritty* ]] \
&& printf " %s TERM=%s\n" "$ok" "$TERM" || printf " %s TERM=%s (may lack color support)\n" "$warn" "$TERM"
[[ "$(locale charmap 2>/dev/null)" == UTF-8 ]] \
&& printf " %s locale is UTF-8\n" "$ok" || printf " %s locale is not UTF-8\n" "$warn"
[[ -n "$(git config user.name)" && -n "$(git config user.email)" ]] \
&& printf " %s git user configured\n" "$ok" || printf " %s git user.name/email not set\n" "$warn"
header "Symlinks"
local stow_ok=true
for pkg in "${ALL_PACKAGES[@]}"; do
[[ -d "$DOTFILES_DIR/$pkg" ]] || continue
if stow --simulate --verbose "$pkg" 2>&1 | grep -q "LINK"; then
printf " $fail %s has missing links\n" "$pkg"
stow_ok=false
fi
done
$stow_ok && printf " %s all stow symlinks intact\n" "$ok"
header "Plugin managers"
fish -c 'type -q fisher' 2>/dev/null && printf " %s fisher present\n" "$ok" || printf " %s fisher not found\n" "$fail"
header "Truecolor test (lines should be continuous)"
fish -c "my-24-bit-color.sh"
header "Clipboard test"
fish -c "echo 123 | my-yank-to-clipboard"
}
show_banner() {
printf '\033[1;35m'
cat << 'EOF'
😈
😈 😈 😈
██████╗ █████╗ ███████╗███████╗██████╗ ██╗ ██╗███╗ ██╗██╗ ██╗██╗ ██╗
██╔══██╗██╔══██╗██╔════╝██╔════╝██╔══██╗ ██║ ██║████╗ ██║██║ ██║╚██╗██╔╝
██████╔╝███████║███████╗█████╗ ██║ ██║ ██║ 😈 ██║██╔██╗ ██║██║ ██║ ╚███╔╝
██╔══██╗██╔══██║╚════██║██╔══╝ ██║ ██║ ██║ ██║██║╚██╗██║██║ ██║ ██╔██╗
██████╔╝██║ ██║███████║███████╗██████╔╝ ███████╗██║██║ ╚████║╚██████╔╝██╔╝ ██╗
╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═════╝ ╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝
😈 😈
██████╗ ██████╗ ███╗ ██╗███████╗██╗ ██████╗ 😈
██╔════╝██╔═══██╗████╗ ██║██╔════╝██║██╔════╝
██║ ██║😈 ██║██╔██╗ ██║█████╗ ██║██║ ███╗ 😈
██║ ██║ ██║██║╚██╗██║██╔══╝ ██║██║ ██║ 😈
╚██████╗╚██████╔╝██║ ╚████║██║ ██║╚██████╔╝
╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝
😈
😈██████╗ ███████╗██████╗ ██╗ 😈 ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔════╝██╔══██╗██║ ██╔═══██╗╚██╗ ██╔╝██╔════╝██╔══██╗
██║ ██║█████╗ ██████╔╝██║ ██║ ██║ ╚████╔╝ █████╗ ██║ ██║
██║ ██║██╔══╝ ██╔═══╝ ██║ ██║ ██║ ╚██╔╝ ██╔══╝ ██║ ██║ 😈
██████╔╝███████╗██║ 😈 ███████╗╚██████╔╝ ██║ ███████╗██████╔╝
╚═════╝ ╚══════╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═════╝
😈 😈
█████╗ ███╗ 😈██╗██████╗ ██████╗ ███████╗ █████╗ ██████╗ ██╗ ██╗
██╔══██╗████╗ ██║██╔══██╗ ██╔══██╗██╔════╝██╔══██╗██╔══██╗╚██╗ ██╔╝
███████║██╔██╗ ██║██║ ██║ 😈 ██████╔╝█████╗ ███████║██║ ██║ ╚████╔╝
██╔══██║██║╚██╗██║██║ ██║ ██╔══██╗██╔══╝ ██╔══██║██║ ██║ ╚██╔╝ 😈
██║ ██║██║ ╚████║██████╔╝ ██║ ██║███████╗██║ ██║██████╔╝ ██║
╚═╝ ╚═╝╚═╝ ╚═══╝╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝
😈 😈
😈
EOF
printf '\033[0m'
}
usage() {
cat <<-EOF
Usage: $(basename "$0") <command>
Commands:
install [term|desktop|all] Link dotfiles and install plugins (default: all)
update Update all managed plugins
unlink Remove all symlinks from \$HOME
health Verify setup
Options:
-h, --help Show this help
EOF
}
# --- Main ---
case "${1:-}" in
install) shift; cmd_install "${1:-all}" ;;
update) cmd_update ;;
unlink) cmd_unlink ;;
health) cmd_health ;;
-h|--help)
usage
;;
*)
usage
exit 1
;;
esac