-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·140 lines (124 loc) · 3.82 KB
/
bootstrap.sh
File metadata and controls
executable file
·140 lines (124 loc) · 3.82 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
#!/bin/sh
set -eu
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# --- Colors & Symbols ---
if [ -t 1 ]; then
BOLD="\033[1m"
DIM="\033[2m"
RED="\033[31m"
GREEN="\033[32m"
YELLOW="\033[33m"
BLUE="\033[34m"
MAGENTA="\033[35m"
CYAN="\033[36m"
RESET="\033[0m"
else
BOLD="" DIM="" RED="" GREEN="" YELLOW="" BLUE="" MAGENTA="" CYAN="" RESET=""
fi
ARROW="${CYAN}==>${RESET}"
CHECK="${GREEN}✓${RESET}"
SKIP="${YELLOW}⏭${RESET}"
GEAR="${BLUE}⚙${RESET}"
info() { printf "${ARROW} ${BOLD}%s${RESET}\n" "$1"; }
ok() { printf " ${CHECK} %s\n" "$1"; }
skip() { printf " ${SKIP} ${DIM}%s${RESET}\n" "$1"; }
warn() { printf " ${YELLOW}! %s${RESET}\n" "$1"; }
step() { printf " ${GEAR} %s\n" "$1"; }
# --- Banner ---
printf "\n"
printf "${MAGENTA}${BOLD}"
printf " ╔══════════════════════════════════════╗\n"
printf " ║ nix-setup bootstrap ║\n"
printf " ╚══════════════════════════════════════╝\n"
printf "${RESET}"
printf "${DIM} %s @ %s${RESET}\n" "$(whoami)" "$(hostname)"
printf "${DIM} %s %s${RESET}\n" "$(uname -s)" "$(uname -m)"
printf "\n"
# --- Homebrew ---
info "Homebrew"
if command -v brew >/dev/null 2>&1; then
skip "Already installed ($(brew --version | head -1))"
else
step "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [ "$(uname -m)" = "arm64" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
else
eval "$(/usr/local/bin/brew shellenv)"
fi
ok "Homebrew installed"
fi
# --- Brewfile ---
info "Brewfile dependencies"
step "Running brew bundle..."
brew bundle --file="$SCRIPT_DIR/Brewfile"
ok "All formulae and casks installed"
# --- Submodules ---
info "Submodules"
step "Updating dotfiles submodule..."
git -C "$SCRIPT_DIR" submodule update --init --recursive
ok "Submodules up to date"
# --- oh-my-zsh ---
info "oh-my-zsh"
if [ -d "${ZSH:-$HOME/.oh-my-zsh}" ]; then
skip "Already installed"
else
step "Installing oh-my-zsh..."
KEEP_ZSHRC=yes sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
ok "oh-my-zsh installed"
fi
# --- chezmoi ---
info "chezmoi"
step "Initializing (this will prompt for config values)..."
printf "\n"
chezmoi init "$SCRIPT_DIR/dotfiles"
ok "chezmoi initialized"
step "Previewing changes..."
printf "\n"
if [ -n "$(chezmoi status)" ]; then
chezmoi diff --pager cat
printf "\n"
printf " ${YELLOW}${BOLD}Apply these changes? [y/N]${RESET} "
read -r answer
case "$answer" in
[yY]|[yY][eE][sS])
step "Applying dotfiles..."
chezmoi apply
ok "Dotfiles applied"
;;
*)
warn "Aborted. Run 'chezmoi apply' manually when ready."
;;
esac
else
skip "Already up to date – nothing to apply"
fi
# --- Claude Code ---
info "Claude Code"
if command -v claude >/dev/null 2>&1; then
skip "Already installed ($(claude --version))"
else
step "Installing Claude Code..."
curl -fsSL https://claude.ai/install.sh | bash
ok "Claude Code installed"
fi
# --- sheldon ---
info "sheldon"
step "Locking plugins..."
sheldon lock
ok "Plugins locked"
# --- mise ---
info "mise"
step "Installing tool versions..."
mise install
ok "All tools installed"
# --- Done ---
printf "\n"
printf "${GREEN}${BOLD}"
printf " ╔══════════════════════════════════════╗\n"
printf " ║ Bootstrap complete! ║\n"
printf " ╚══════════════════════════════════════╝\n"
printf "${RESET}"
printf "\n"
printf " Restart your shell or run: ${CYAN}exec \$SHELL${RESET}\n"
printf "\n"