-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·259 lines (212 loc) · 8.46 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·259 lines (212 loc) · 8.46 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
#!/usr/bin/env bash
set -euo pipefail
DOTFILES="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TOTAL_STEPS=7
STEP=0
# ── Helpers ──
step() {
STEP=$((STEP + 1))
echo ""
echo "── Step $STEP/$TOTAL_STEPS: $1 ──"
}
ok() { echo " ✓ $1"; }
info() { echo " → $1"; }
warn() { echo " ⚠ $1"; }
pause() {
echo ""
read -rp " Press Enter to continue..." </dev/tty
}
# ── Step 1: Homebrew ──
step "Homebrew"
# Always ensure brew is in PATH (even on re-runs where .zprofile isn't stowed yet)
if [ -x /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
ok "Already installed"
elif command -v brew &>/dev/null; then
ok "Already installed"
else
info "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
ok "Installed"
fi
# ── Step 2: SSH Keys ──
step "SSH Keys"
if [ -f "$HOME/.ssh/id_ed25519" ]; then
ok "Key exists at ~/.ssh/id_ed25519"
else
info "Generating SSH key..."
ssh-keygen -t ed25519 -C "tlrc1984@gmail.com" </dev/tty
eval "$(ssh-agent -s)" > /dev/null 2>&1
ssh-add --apple-use-keychain "$HOME/.ssh/id_ed25519"
ok "Key generated"
# Persist key across reboots via macOS Keychain
if [ ! -f "$HOME/.ssh/config" ]; then
cat > "$HOME/.ssh/config" << 'SSHEOF'
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519
SSHEOF
chmod 600 "$HOME/.ssh/config"
ok "SSH config created (key will persist across reboots)"
fi
echo ""
echo " Your public key:"
echo ""
cat "$HOME/.ssh/id_ed25519.pub"
echo ""
warn "Add this key to GitHub: https://github.com/settings/keys"
pause
fi
# Switch remote to SSH if currently HTTPS (supports initial HTTPS clone)
if git -C "$DOTFILES" remote get-url origin 2>/dev/null | grep -q "^https://"; then
git -C "$DOTFILES" remote set-url origin "git@github.com:Trolzie/dotfiles-essentials.git"
ok "Switched git remote to SSH"
fi
# ── Step 3: Shell setup ──
step "Shell (oh-my-zsh + plugins + Powerlevel10k)"
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
if [ -d "$HOME/.oh-my-zsh" ]; then
ok "oh-my-zsh already installed"
else
info "Installing oh-my-zsh..."
RUNZSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
ok "oh-my-zsh installed"
fi
if [ -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]; then
ok "zsh-syntax-highlighting already installed"
else
info "Installing zsh-syntax-highlighting..."
git clone --quiet https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
ok "zsh-syntax-highlighting installed"
fi
if [ -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]; then
ok "zsh-autosuggestions already installed"
else
info "Installing zsh-autosuggestions..."
git clone --quiet https://github.com/zsh-users/zsh-autosuggestions.git "$ZSH_CUSTOM/plugins/zsh-autosuggestions"
ok "zsh-autosuggestions installed"
fi
if [ -d "$ZSH_CUSTOM/themes/powerlevel10k" ]; then
ok "Powerlevel10k already installed"
else
info "Installing Powerlevel10k..."
git clone --quiet --depth=1 https://github.com/romkatv/powerlevel10k.git "$ZSH_CUSTOM/themes/powerlevel10k"
ok "Powerlevel10k installed"
fi
# ── Step 4: macOS defaults ──
step "macOS defaults"
info "Setting keyboard repeat, disabling smart quotes, Finder prefs..."
# Keyboard & Input
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Trackpad
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool true
# Finder
defaults write com.apple.finder AppleShowAllFiles -bool true
defaults write com.apple.finder ShowPathbar -bool true
defaults write com.apple.finder ShowStatusBar -bool true
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
defaults write com.apple.finder DisableAllAnimations -bool true
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
# Dock
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -float 0
defaults write com.apple.dock tilesize -int 34
defaults write com.apple.dock mineffect -string "scale"
defaults write com.apple.dock show-recents -bool false
defaults write com.apple.dock launchanim -bool false
defaults write com.apple.dock expose-animation-duration -float 0.1
defaults write com.apple.dock minimize-to-application -bool true
# Animations
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
# Screenshots
defaults write com.apple.screencapture disable-shadow -bool true
# Time Machine
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
# Locale
defaults write NSGlobalDomain AppleLanguages -array "en" "nl"
defaults write NSGlobalDomain AppleLocale -string "en_GB@currency=EUR"
defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
defaults write NSGlobalDomain AppleMetricUnits -bool true
# Misc
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
defaults write com.apple.LaunchServices LSQuarantine -bool false
# These need sudo — skip if not available
if sudo -n true 2>/dev/null; then
sudo defaults write com.apple.universalaccess reduceMotion -bool true 2>/dev/null
sudo systemsetup -settimezone "Europe/Copenhagen" > /dev/null 2>&1
sudo nvram SystemAudioVolume=" " 2>/dev/null
sudo nvram StartupMute=%01 2>/dev/null
ok "All defaults set (including reduce motion, boot sound + timezone)"
else
warn "Skipped reduce motion, boot sound + timezone (need sudo). Run with sudo later if needed."
ok "User defaults set"
fi
# Restart affected apps so changes apply immediately
killall Dock 2>/dev/null || true
killall Finder 2>/dev/null || true
killall SystemUIServer 2>/dev/null || true
ok "Dock and Finder restarted"
# ── Step 5: Node.js ──
step "Node.js (nvm)"
export NVM_DIR="$HOME/.nvm"
if [ -d "$NVM_DIR" ]; then
ok "nvm already installed"
else
info "Installing nvm..."
PROFILE=/dev/null bash -c "$(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh)"
ok "nvm installed"
fi
# Load nvm and install LTS if not present
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
if command -v nvm &>/dev/null; then
if nvm which "lts/*" &>/dev/null; then
ok "Node.js LTS already installed"
else
info "Installing Node.js LTS..."
nvm install --lts
ok "Node.js LTS installed"
fi
fi
# ── Step 6: Claude Code ──
step "Claude Code"
if command -v claude &>/dev/null; then
ok "Already installed"
else
info "Installing Claude Code..."
curl -fsSL https://claude.ai/install.sh | bash
ok "Claude Code installed"
fi
# ── Step 7: Sync (brew packages + symlinks) ──
step "Sync"
bash "$DOTFILES/sync.sh"
# ── Done ──
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " All done! Restart your terminal, then run:"
echo ""
echo " p10k configure"
echo ""
echo " Optional: copy ~/.secrets from your backup"
echo " chmod 600 ~/.secrets"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"