-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathjustfile
More file actions
198 lines (165 loc) · 6.46 KB
/
justfile
File metadata and controls
198 lines (165 loc) · 6.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
dotfiles_dir := justfile_directory()
config_dir := env("HOME") / ".config"
# List available recipes
default:
@just --list
# Link stow configs + create convenience symlinks in dotfiles dir
link:
stow -R xdg-configs -t "{{ config_dir }}"
stow -R bin -t "{{ env("HOME") }}/bin"
ln -sfn "{{ config_dir }}/nvim" "{{ dotfiles_dir }}/nvim"
ln -sfn "$HOME/.claude" "{{ dotfiles_dir }}/dot-claude"
if [ ! -e "{{ env("HOME") }}/.zshenv" ]; then printf '%s\n' '[[ -r "$HOME/.config/zsh/zshenv" ]] && source "$HOME/.config/zsh/zshenv"' > "{{ env("HOME") }}/.zshenv"; fi
if [ ! -e "{{ env("HOME") }}/.zshrc" ]; then printf '%s\n' '_zsh_config_home="${ZSH_CONFIG_HOME:-$HOME/.config/zsh}"' '[[ -r "$_zsh_config_home/zshrc" ]] && source "$_zsh_config_home/zshrc"' 'unset _zsh_config_home' > "{{ env("HOME") }}/.zshrc"; fi
# Unlink stow configs + remove convenience symlinks
unlink:
stow -D xdg-configs -t "{{ config_dir }}"
stow -D bin -t "{{ env("HOME") }}/bin"
rm -f "{{ dotfiles_dir }}/nvim"
rm -f "{{ dotfiles_dir }}/dot-claude"
# Clone external repos if not already present
repos:
#!/usr/bin/env bash
set -euo pipefail
clone_if_missing() {
local url="$1" dest="$2"
if [ -d "$dest/.git" ]; then
echo "✓ $dest already exists"
else
echo "→ Cloning $url into $dest"
git clone "$url" "$dest"
fi
}
clone_if_missing "https://github.com/luan/nvim" "{{ config_dir }}/nvim"
clone_if_missing "https://github.com/luan/dot-claude" "$HOME/.claude"
# Safely pull dotfiles + external repos (skips repos with uncommitted changes)
pull:
#!/usr/bin/env bash
set -euo pipefail
safe_pull() {
local dir="$1" name="$2"
if [ ! -d "$dir/.git" ]; then
echo "⚠ $name: not a git repo, skipping"
return
fi
if [ -n "$(git -C "$dir" status --porcelain)" ]; then
echo "⚠ $name: uncommitted changes, skipping"
return
fi
echo "→ Pulling $name"
git -C "$dir" pull --rebase --quiet && echo "✓ $name up to date" || echo "✗ $name pull failed"
}
safe_pull "{{ dotfiles_dir }}" "dotfiles"
safe_pull "{{ config_dir }}/nvim" "nvim"
safe_pull "$HOME/.claude" "dot-claude"
# Install Homebrew packages from Brewfile
brew:
brew bundle --file="{{ dotfiles_dir }}/Brewfile"
# Resolve and lock sheldon plugins (called during setup)
sheldon:
sheldon --config-file "{{ dotfiles_dir }}/xdg-configs/sheldon/plugins.toml" lock --update
# Set Homebrew zsh as login shell (registers in /etc/shells if missing; needs sudo for that step)
chsh-zsh:
#!/usr/bin/env bash
set -euo pipefail
ZSH_BIN="/opt/homebrew/bin/zsh"
if [ ! -x "$ZSH_BIN" ]; then
echo "✗ $ZSH_BIN not found — run 'just brew' first" >&2
exit 1
fi
if ! grep -qxF "$ZSH_BIN" /etc/shells; then
echo "→ Registering $ZSH_BIN in /etc/shells (sudo)"
echo "$ZSH_BIN" | sudo tee -a /etc/shells >/dev/null
fi
current=$(dscl . -read "/Users/$USER" UserShell 2>/dev/null | awk '{print $2}')
if [ "$current" = "$ZSH_BIN" ]; then
echo "✓ Login shell already $ZSH_BIN"
else
echo "→ Changing login shell: $current → $ZSH_BIN"
chsh -s "$ZSH_BIN"
fi
# Apply macOS system defaults
macos-defaults:
source "{{ dotfiles_dir }}/macos-defaults.sh"
# Set up git config include
gitconfig:
#!/usr/bin/env bash
set -euo pipefail
if ! grep -q "path={{ dotfiles_dir }}/gitconfig" "$HOME/.gitconfig" 2>/dev/null; then
echo -e "\n[include]\n path={{ dotfiles_dir }}/gitconfig" >> "$HOME/.gitconfig"
echo "✓ Added gitconfig include"
else
echo "✓ gitconfig already configured"
fi
# Install Claude Code plugin marketplaces and plugins
claude-plugins:
#!/usr/bin/env bash
set -euo pipefail
if ! command -v claude &>/dev/null; then
echo "⚠ claude not found, skipping plugin setup"
exit 0
fi
marketplaces=(
"anthropics/claude-plugins-official"
)
plugins=(
"clangd-lsp@claude-plugins-official"
"context7@claude-plugins-official"
"gopls-lsp@claude-plugins-official"
"pyright-lsp@claude-plugins-official"
"rust-analyzer-lsp@claude-plugins-official"
"swift-lsp@claude-plugins-official"
)
for m in "${marketplaces[@]}"; do
echo "→ Marketplace: $m"
claude plugin marketplace add "$m" 2>/dev/null || true
done
for p in "${plugins[@]}"; do
echo "→ Plugin: $p"
claude plugin install "$p" 2>/dev/null || true
done
echo "✓ Claude plugins ready"
# Install cargo binaries via cargo-binstall
cargo:
#!/usr/bin/env bash
set -euo pipefail
if ! command -v cargo-binstall &>/dev/null; then
echo "⚠ cargo-binstall not found, run 'just brew' first"
exit 1
fi
crates=(
"ck-search"
)
for crate in "${crates[@]}"; do
echo "→ $crate"
cargo binstall "$crate" --no-confirm --quiet 2>/dev/null || echo "✗ $crate install failed"
done
echo "✓ Cargo binaries ready"
# Set up local dev-routing (Caddy + dnsmasq subdomain routing)
dev-routing: link
#!/usr/bin/env bash
set -euo pipefail
"$HOME/bin/dev-routing" setup && "$HOME/bin/dev-routing" scan
# Run dot-claude setup (ct tool + completions)
dot-claude:
#!/usr/bin/env bash
set -euo pipefail
if [ -f "$HOME/.claude/justfile" ]; then
echo "→ Running dot-claude setup"
just -f "$HOME/.claude/justfile" setup
else
echo "⚠ dot-claude justfile not found, skipping"
fi
# Build mux binary (Rust)
mux:
cargo build --release --manifest-path="{{ dotfiles_dir }}/xdg-configs/tmux/mux/Cargo.toml"
mkdir -p "{{ env("HOME") }}/bin" "{{ config_dir }}/tmux/scripts"
cp "{{ dotfiles_dir }}/xdg-configs/tmux/mux/target/release/mux" "{{ env("HOME") }}/bin/mux"
codesign --force --sign - "{{ env("HOME") }}/bin/mux"
rm -f "{{ config_dir }}/tmux/scripts/mux"
ln -s "{{ env("HOME") }}/bin/mux" "{{ config_dir }}/tmux/scripts/mux"
swiftc -O -o "{{ env("HOME") }}/bin/notch-state" "{{ dotfiles_dir }}/xdg-configs/tmux/mux/scripts/notch-state.swift"
codesign --force --sign - "{{ env("HOME") }}/bin/notch-state"
@echo "✓ mux built"
# Full setup: brew, cargo, repos, link, gitconfig, claude-plugins, dev-routing, dot-claude, mux, sheldon
setup: brew cargo repos link gitconfig claude-plugins dev-routing dot-claude mux sheldon