-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
307 lines (252 loc) · 9.76 KB
/
Justfile
File metadata and controls
307 lines (252 loc) · 9.76 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
# Cross-Platform Mac/Linux Setup Automation
# Requires: just (brew install just)
# Usage: just <recipe>
# Default recipe - show available commands
default:
@just --list
# Detect OS
os := if os() == "macos" { "darwin" } else { "linux" }
brew_prefix := if os() == "macos" { "/opt/homebrew" } else { "/home/linuxbrew/.linuxbrew" }
# ============================================================================
# Main Workflows
# ============================================================================
# Complete system bootstrap (run this first!)
bootstrap: install-homebrew install-tools setup-shell setup-vim setup-vscode macos-settings
@echo "[OK] Bootstrap complete!"
@echo "Please restart your terminal to activate changes"
# Quick update (packages + dotfiles)
update: brew-update mise-update
@echo "[OK] System updated!"
# ============================================================================
# Homebrew
# ============================================================================
# Install Homebrew (if not present)
install-homebrew:
#!/usr/bin/env bash
set -euo pipefail
if ! command -v brew &> /dev/null; then
echo "[INSTALL] Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add to PATH for this session
if [ "{{ os }}" = "linux" ]; then
eval "$({{ brew_prefix }}/bin/brew shellenv)"
fi
else
echo "[OK] Homebrew already installed"
fi
# Install all packages from Brewfile
brew-install: install-homebrew
@echo "[INSTALL] Installing packages from Brewfile..."
brew bundle install --file=Brewfile
# Update all Homebrew packages
brew-update:
@echo "[INSTALL] Updating Homebrew packages..."
brew update
brew upgrade
brew cleanup
# ============================================================================
# Development Tools
# ============================================================================
# Install all tools (mise, packages, etc.)
install-tools: install-homebrew brew-install install-mise
@echo "[OK] All tools installed"
# Install mise and tool versions
install-mise:
#!/usr/bin/env bash
set -euo pipefail
if ! command -v mise &> /dev/null; then
echo "[INSTALL] Installing mise..."
brew install mise
fi
echo "[INSTALL] Installing tool versions from .mise.toml..."
mise install
# Update mise tools
mise-update:
@echo "[INSTALL] Updating mise tools..."
mise upgrade
mise prune
# ============================================================================
# Shell Configuration
# ============================================================================
# Setup Zsh with Oh My Zsh + Powerlevel10k
setup-shell:
#!/usr/bin/env bash
set -euo pipefail
# Install Oh My Zsh
if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo "[SHELL] Installing Oh My Zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
# Install Powerlevel10k theme
if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" ]; then
echo "🎨 Installing Powerlevel10k theme..."
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
fi
# Install zsh plugins
echo "[PLUGIN] Installing zsh plugins..."
# zsh-syntax-highlighting
if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" ]; then
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
fi
# zsh-autosuggestions
if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
fi
# zsh-completions
if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-completions" ]; then
git clone https://github.com/zsh-users/zsh-completions \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-completions
fi
echo "[OK] Shell setup complete!"
echo "[NOTE] Copy dotfiles/.zshrc to ~/.zshrc or use chezmoi"
# ============================================================================
# Vim Configuration
# ============================================================================
# Setup Vim with plugins
setup-vim:
#!/usr/bin/env bash
set -euo pipefail
# Install vim-plug
if [ ! -f "$HOME/.vim/autoload/plug.vim" ]; then
echo "[NOTE] Installing vim-plug..."
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
echo "[OK] Vim setup complete!"
echo "[NOTE] Run :PlugInstall in vim to install plugins"
# ============================================================================
# VS Code Configuration
# ============================================================================
# Install VS Code extensions
setup-vscode:
#!/usr/bin/env bash
set -euo pipefail
if ! command -v code &> /dev/null; then
echo "⚠️ VS Code not found. Install it first."
exit 1
fi
echo "[PLUGIN] Installing VS Code extensions..."
# Extensions list from group_vars/all.yml
extensions=(
"streetsidesoftware.code-spell-checker"
"wholroyd.jinja"
"ms-python.python"
"esbenp.prettier-vscode"
"eamodio.gitlens"
"donjayamanne.githistory"
"idleberg.icon-fonts"
"vscode-icons-team.vscode-icons"
"wayou.vscode-todo-highlight"
"johnpapa.vscode-peacock"
"christian-kohler.path-intellisense"
"yzhang.markdown-all-in-one"
"aaron-bond.better-comments"
"zhuangtongfa.Material-theme"
"wesbos.theme-cobalt2"
"redhat.vscode-yaml"
"redhat.ansible"
"ms-kubernetes-tools.vscode-kubernetes-tools"
"dbaeumer.vscode-eslint"
"ms-azuretools.vscode-docker"
"github.vscode-pull-request-github"
"ibm.output-colorizer"
"hashicorp.terraform"
"oderwat.indent-rainbow"
"pkief.material-icon-theme"
)
for ext in "${extensions[@]}"; do
if ! code --list-extensions | grep -q "^$ext$"; then
echo "Installing $ext..."
code --install-extension "$ext"
else
echo "[OK] $ext already installed"
fi
done
echo "[OK] VS Code extensions installed!"
# ============================================================================
# macOS-Specific
# ============================================================================
# Configure macOS system settings (macOS only)
macos-settings:
#!/usr/bin/env bash
set -euo pipefail
if [ "{{ os }}" != "darwin" ]; then
echo "[SKIP] Skipping macOS settings (not on macOS)"
exit 0
fi
echo "[CONFIG] Configuring macOS settings..."
# Add your macOS defaults here
# Example:
# defaults write com.apple.dock autohide -bool true
# killall Dock
echo "[OK] macOS settings configured!"
# Configure macOS Dock (macOS only)
setup-dock:
#!/usr/bin/env bash
set -euo pipefail
if [ "{{ os }}" != "darwin" ]; then
echo "[SKIP] Skipping Dock setup (not on macOS)"
exit 0
fi
if ! command -v dockutil &> /dev/null; then
echo "[INSTALL] Installing dockutil..."
brew install dockutil
fi
echo "[DOCK] Configuring Dock..."
# Add your dock configuration here
# Example:
# dockutil --remove 'TV' --no-restart
# dockutil --add '/Applications/iTerm.app' --no-restart
killall Dock
echo "[OK] Dock configured!"
# ============================================================================
# Chezmoi (Dotfiles)
# ============================================================================
# Initialize chezmoi and apply dotfiles
dotfiles-init:
#!/usr/bin/env bash
set -euo pipefail
if ! command -v chezmoi &> /dev/null; then
echo "[INSTALL] Installing chezmoi..."
brew install chezmoi
fi
if [ ! -d "$HOME/.local/share/chezmoi" ]; then
echo "🏗️ Initializing chezmoi..."
chezmoi init
# Copy initial dotfiles
echo "[NOTE] Adding dotfiles..."
cp dotfiles/.zshrc ~/.zshrc
chezmoi add ~/.zshrc
else
echo "[OK] chezmoi already initialized"
fi
# Apply dotfiles from chezmoi
dotfiles-apply:
@echo "[NOTE] Applying dotfiles..."
chezmoi apply
# Edit dotfiles with chezmoi
dotfiles-edit file:
chezmoi edit {{ file }}
# ============================================================================
# Cleanup
# ============================================================================
# Clean up caches and old files
clean:
@echo "[CLEAN] Cleaning up..."
brew cleanup
mise cache clear
@echo "[OK] Cleanup complete!"
# ============================================================================
# Info
# ============================================================================
# Show system information
info:
@echo "[SYSTEM] System: {{ os }}"
@echo "[INSTALL] Homebrew prefix: {{ brew_prefix }}"
@command -v brew &> /dev/null && echo "[OK] Homebrew: $(brew --version | head -n1)" || echo "[ERROR] Homebrew: not installed"
@command -v mise &> /dev/null && echo "[OK] mise: $(mise --version)" || echo "[ERROR] mise: not installed"
@command -v chezmoi &> /dev/null && echo "[OK] chezmoi: $(chezmoi --version)" || echo "[ERROR] chezmoi: not installed"
@command -v code &> /dev/null && echo "[OK] VS Code: installed" || echo "[ERROR] VS Code: not installed"