-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·386 lines (340 loc) · 9.86 KB
/
install.sh
File metadata and controls
executable file
·386 lines (340 loc) · 9.86 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
#!/usr/bin/env bash
#
# install.sh — Install all tools and prerequisites for these dotfiles.
#
# Supports macOS (Homebrew) and Arch Linux (pacman + yay).
#
# Usage:
# ./install.sh Install everything for the current platform
# ./install.sh --help Show this help message
#
set -euo pipefail
# ---------------------------------------------------------------------------
# Colors
# ---------------------------------------------------------------------------
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
BOLD='\033[1m'
RESET='\033[0m'
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------
info() { printf "${BLUE}::${RESET} %s\n" "$*"; }
success() { printf "${GREEN}::${RESET} %s\n" "$*"; }
warn() { printf "${YELLOW}:: %s${RESET}\n" "$*"; }
error() { printf "${RED}:: %s${RESET}\n" "$*" >&2; }
confirm() {
printf "${BOLD}%s [Y/n]${RESET} " "$1"
read -r answer
case "$answer" in
[nN]*) return 1 ;;
*) return 0 ;;
esac
}
command_exists() { command -v "$1" &>/dev/null; }
# ---------------------------------------------------------------------------
# Detect platform
# ---------------------------------------------------------------------------
OS="$(uname -s)"
case "$OS" in
Darwin) PLATFORM="macos" ;;
Linux) PLATFORM="linux" ;;
*)
error "Unsupported platform: $OS"
exit 1
;;
esac
if [[ "$PLATFORM" == "linux" ]] && ! command_exists pacman; then
error "This script expects Arch Linux (pacman not found)."
error "For other distributions, install the equivalent packages manually."
exit 1
fi
info "Detected platform: $PLATFORM"
# ---------------------------------------------------------------------------
# Package lists
# ---------------------------------------------------------------------------
# Cross-platform tools (installed on both macOS and Linux)
COMMON_TOOLS=(
bat
btop
chezmoi
direnv
eza
fzf
git
git-delta
jq
neovim
pre-commit
ripgrep
shellcheck
shfmt
starship
stylua
tmux
yazi
zoxide
zsh
)
# --- macOS (Homebrew) ---
BREW_FORMULAE=(
"${COMMON_TOOLS[@]}"
nvm
switchaudio-osx
terminal-notifier
)
BREW_CASKS=(
blackhole-2ch
font-jetbrains-mono-nerd-font
font-noto-color-emoji
font-sketchybar-app-font
karabiner-elements
kitty
)
BREW_TAPS=(
jackielii/tap
koekeishiya/formulae
oven-sh/bun
FelixKratz/formulae
)
BREW_TAP_FORMULAE=(
jackielii/tap/skhd-zig
koekeishiya/formulae/yabai
oven-sh/bun/bun
FelixKratz/formulae/sketchybar
FelixKratz/formulae/borders
)
# --- Arch Linux (pacman) ---
PACMAN_PACKAGES=(
"${COMMON_TOOLS[@]}"
kitty
noto-fonts-emoji
nvm
ttf-jetbrains-mono-nerd
firefox
# Hyprland ecosystem
hyprland
hyprlock
hypridle
hyprpaper
hyprsunset
uwsm
# Desktop utilities
blueman
brightnessctl
nautilus
nm-connection-editor
playerctl
qt6ct
# PDF viewer
zathura
zathura-pdf-mupdf
)
AUR_PACKAGES=(
ashell
elephant-all
kanata
pwvucontrol
walker
)
# ---------------------------------------------------------------------------
# macOS installation
# ---------------------------------------------------------------------------
install_macos() {
info "Starting macOS installation..."
# Homebrew
if ! command_exists brew; then
info "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add Homebrew to PATH for the rest of this script
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
else
success "Homebrew already installed"
fi
# Taps
info "Adding Homebrew taps..."
for tap in "${BREW_TAPS[@]}"; do
brew tap "$tap" 2>/dev/null || true
done
# Formulae
info "Installing Homebrew formulae..."
brew install "${BREW_FORMULAE[@]}" || true
# Tap formulae (from custom taps)
info "Installing tools from custom taps..."
brew install "${BREW_TAP_FORMULAE[@]}" || true
# Casks
info "Installing Homebrew casks..."
brew install --cask "${BREW_CASKS[@]}" || true
# Zathura (requires its own tap)
info "Installing Zathura..."
brew tap homebrew-zathura/zathura 2>/dev/null || true
brew install zathura zathura-pdf-mupdf 2>/dev/null || true
# SBarLua (SketchyBar Lua API)
if [[ ! -d "$HOME/.local/share/sketchybar_lua" ]]; then
info "Installing SBarLua..."
git clone https://github.com/FelixKratz/SbarLua.git /tmp/SbarLua &&
(cd /tmp/SbarLua && make install) &&
rm -rf /tmp/SbarLua
success "SBarLua installed"
else
success "SBarLua already installed"
fi
success "macOS packages installed"
}
# ---------------------------------------------------------------------------
# Arch Linux installation
# ---------------------------------------------------------------------------
install_linux() {
info "Starting Arch Linux installation..."
# Sync package databases
info "Updating package databases..."
sudo pacman -Sy --noconfirm
# Official repo packages
info "Installing pacman packages..."
sudo pacman -S --needed --noconfirm "${PACMAN_PACKAGES[@]}"
# AUR helper
if ! command_exists yay; then
info "Installing yay (AUR helper)..."
sudo pacman -S --needed --noconfirm base-devel git
git clone https://aur.archlinux.org/yay.git /tmp/yay
(cd /tmp/yay && makepkg -si --noconfirm)
rm -rf /tmp/yay
success "yay installed"
else
success "yay already installed"
fi
# AUR packages
info "Installing AUR packages..."
yay -S --needed --noconfirm "${AUR_PACKAGES[@]}"
# Enable Kanata systemd service
if command_exists kanata; then
info "Enabling Kanata keyboard remapper service..."
systemctl --user enable kanata.service 2>/dev/null || true
fi
# JDK 21 (Eclipse Temurin)
local jdk_dir="$HOME/.local/jdks"
local jdk_link="$jdk_dir/jdk-21"
if [[ ! -d "$jdk_link" ]]; then
info "Installing JDK 21 (Eclipse Temurin)..."
mkdir -p "$jdk_dir"
curl -fL "https://api.adoptium.net/v3/binary/latest/21/ga/linux/x64/jdk/hotspot/normal/eclipse" \
-o "$jdk_dir/temurin21.tar.gz"
tar -xzf "$jdk_dir/temurin21.tar.gz" -C "$jdk_dir"
rm -f "$jdk_dir/temurin21.tar.gz"
ln -sfn "$jdk_dir"/jdk-21.* "$jdk_link"
success "JDK 21 installed at $jdk_link"
else
success "JDK 21 already installed"
fi
success "Arch Linux packages installed"
}
# ---------------------------------------------------------------------------
# Cross-platform post-install setup
# ---------------------------------------------------------------------------
setup_common() {
info "Running post-install setup..."
# TPM (Tmux Plugin Manager)
local tpm_dir="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/plugins/tpm"
if [[ ! -d "$tpm_dir" ]]; then
info "Installing TPM (Tmux Plugin Manager)..."
git clone https://github.com/tmux-plugins/tpm "$tpm_dir"
success "TPM installed — press prefix + I inside tmux to install plugins"
else
success "TPM already installed"
fi
# Claude Code
if ! command_exists claude; then
if confirm "Install Claude Code CLI?"; then
curl -fsSL https://claude.ai/install.sh | bash
success "Claude Code installed"
else
warn "Skipping Claude Code"
fi
else
success "Claude Code already installed"
fi
# chezmoi init
if confirm "Apply dotfiles with chezmoi now?"; then
if [[ -d "$HOME/.local/share/chezmoi" ]]; then
info "Applying chezmoi..."
chezmoi apply
else
info "Initializing chezmoi from this directory..."
chezmoi init --apply --source "$(cd "$(dirname "$0")" && pwd)"
fi
success "Dotfiles applied"
else
warn "Skipping chezmoi apply — run 'chezmoi apply' when ready"
fi
# Set default shell to Homebrew's Zsh (macOS) or system Zsh (Linux)
local target_zsh
if [[ "$PLATFORM" == "macos" ]] && [[ -x /opt/homebrew/bin/zsh ]]; then
target_zsh="/opt/homebrew/bin/zsh"
else
target_zsh="$(which zsh)"
fi
local current_shell
current_shell="$(basename "$SHELL")"
if [[ "$current_shell" != "zsh" ]] || [[ "$SHELL" != "$target_zsh" ]]; then
if ! grep -qxF "$target_zsh" /etc/shells; then
info "Adding $target_zsh to /etc/shells..."
echo "$target_zsh" | sudo tee -a /etc/shells >/dev/null
fi
if confirm "Change default shell to $target_zsh?"; then
chsh -s "$target_zsh"
success "Default shell changed to $target_zsh (takes effect on next login)"
fi
else
success "Default shell is already $target_zsh"
fi
}
# ---------------------------------------------------------------------------
# Summary
# ---------------------------------------------------------------------------
print_summary() {
echo ""
printf '%s%sInstallation complete!%s\n' "$GREEN" "$BOLD" "$RESET"
echo ""
echo "Next steps:"
echo " 1. Open a new terminal (or restart your shell)"
echo " 2. Inside tmux, press Ctrl+Space then I to install tmux plugins"
echo " 3. Open Neovim — LazyVim will install plugins on first launch"
if [[ "$PLATFORM" == "macos" ]]; then
echo " 4. Start your window manager: yabai + skhd"
echo " 5. Start SketchyBar: brew services start sketchybar"
else
echo " 4. Log out and back in to start Hyprland via uwsm"
fi
echo ""
}
# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
main() {
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
head -11 "$0" | tail -8 | sed 's/^# *//'
exit 0
fi
echo ""
printf '%sDotfiles Installer%s\n' "$BOLD" "$RESET"
echo "This will install all tools and prerequisites."
echo ""
if ! confirm "Continue?"; then
info "Aborted."
exit 0
fi
echo ""
case "$PLATFORM" in
macos) install_macos ;;
linux) install_linux ;;
esac
setup_common
print_summary
}
main "$@"