-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsetup
More file actions
executable file
·215 lines (191 loc) · 6.84 KB
/
Copy pathsetup
File metadata and controls
executable file
·215 lines (191 loc) · 6.84 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
#!/bin/bash
set -euo pipefail
info() { echo -e " \033[38;5;252m $*\033[0m"; }
success() { echo -e " \033[32m\033[1m $*\033[0m"; }
warn() { echo -e " \033[38;5;137m $*\033[0m"; }
link() {
mkdir -p "$(dirname "$2")"
if [ -L "$2" ]; then
ln -sfn "$1" "$2"
elif [ -e "$2" ]; then
warn "Skipping $2, real file exists (move it aside to link)."
else
ln -s "$1" "$2"
success "Linked $1 to $2"
fi
}
copy() {
mkdir -p "$(dirname "$2")"
rm -rf "$2"
cp -rf "$1" "$2"
success "Copied $1 to $2"
}
info "Setting caarlos0/dotfiles up"
host="$(hostname -s)"
info "Setting up for $host"
# bins
link "$PWD"/bin ~/.bin
if which tmux &>/dev/null; then
link "$PWD"/tmux/tmux.conf ~/.config/tmux/tmux.conf
tmux source ~/.config/tmux/tmux.conf 2>/dev/null || true
fi
# shell
link "$PWD"/fish/functions ~/.config/fish/functions
link "$PWD"/fish/config.fish ~/.config/fish/config.fish
# ssh
for f in "$PWD"/ssh/*; do
link "$f" ~/.ssh/"$(basename "$f")"
done
if [[ $OSTYPE == 'darwin'* ]] && [ -f ~/.ssh/id_ed25519 ]; then
ssh-add --apple-use-keychain ~/.ssh/id_ed25519 &>/dev/null ||
warn "Could not add SSH key to keychain, skipping"
fi
# terms
link "$PWD"/ghostty/config ~/.config/ghostty/config
link "$PWD"/rio ~/.config/rio
# neovim
if which nvim &>/dev/null; then
link "$PWD"/nvim ~/.config/nvim
nvim --headless +"lua vim.pack.update(nil, { force = true })" +qa &>/dev/null
fi
# copilot
if which copilot &>/dev/null; then
info "Setting up Copilot CLI"
copilot_config=$(copilot config --list)
cfg() {
if grep -Fxq -- "$1=$2" <<<"$copilot_config"; then
return
fi
copilot config "$@" >/dev/null
success "Set Copilot $1"
}
cfg theme default
cfg mergeStrategy rebase
cfg showTimestamps true
# shellcheck disable=SC2088 # Keep the path template literal.
cfg worktreePathTemplate '~/Developer/worktrees/{repo}/{branch}'
cfg terminalProgress true
cfg editorMode vim
cfg beep true
cfg updateTerminalTitle false
cfg experimental true
# footer
cfg footer.showModelEffort false
cfg footer.showDirectory false
cfg footer.showBranch true
cfg footer.showContextWindow false
cfg footer.showQuota false
cfg footer.showAiUsed false
cfg footer.showAgent true
cfg footer.showCodeChanges true
cfg footer.showUsername false
cfg footer.showSandbox true
cfg footer.showYolo true
cfg footer.showCiStatus true
cfg footer.showSchedules true
cfg footer.showPullRequest true
cfg footer.showCustom false
# sandbox
cfg sandbox.enabled true
cfg sandbox.sandboxMcpServers true
cfg sandbox.sandboxLspServers true
cfg sandbox.allowBypass true
cfg sandbox.auth.git true
cfg sandbox.auth.gh true
cfg sandbox.allowDevToolAccess true
cfg sandbox.addCurrentWorkingDirectory true
cfg sandbox.userPolicy.filesystem.readonlyPaths "$PWD"
cfg sandbox.userPolicy.network.allowOutbound true
cfg sandbox.userPolicy.network.allowLocalNetwork true
# model
cfg model gpt-6-astra
cfg planModel gpt-6-astra
cfg effortLevel high
cfg planEffortLevel xhigh
cfg contextTier long_context
cfg planContextTier long_context
success "Copilot configuration is up to date"
info "Checking Copilot plugin marketplace"
copilot_marketplaces=$(copilot plugin marketplace list)
if ! grep -Fwq andyfeller/plugins <<<"$copilot_marketplaces"; then
info "Installing the infographic Copilot plugin"
copilot plugin marketplace add andyfeller/plugins >/dev/null
copilot plugin install infographic@andyfeller >/dev/null
cfg sandbox.userPolicy.filesystem.readonlyPaths ~/.copilot/installed-plugins/andyfeller/infographic
success "Installed the infographic Copilot plugin"
fi
info "Updating Copilot plugins"
copilot plugin update --all >/dev/null
success "Updated Copilot plugins"
info "Copying Copilot agents and skills"
mkdir -p ~/.copilot/{agents,skills}/
for agent in "$PWD"/agents/*; do
[ -f "$agent" ] || continue
copy "$agent" ~/.copilot/agents/"$(basename "$agent")"
done
for skill in "$PWD"/skills/*; do
[ -d "$skill" ] || continue
copy "$skill" ~/.copilot/skills/"$(basename "$skill")"
done
if which gh &>/dev/null; then
info "Installing shared Copilot skills"
gh skill install github/gh-stack --agent github-copilot --all --scope user --force >/dev/null 2>&1
gh skill install ayghri/i-have-adhd i-have-adhd --agent github-copilot --scope user --force >/dev/null 2>&1
success "Installed shared Copilot skills"
else
warn "GitHub CLI not found, skipping shared Copilot skills" >&2
fi
info "Generating Copilot Fish completions"
mkdir -p ~/.config/fish/completions/
copilot completion fish >~/.config/fish/completions/copilot.fish
success "Copilot CLI setup complete"
else
warn "Copilot CLI not found, skipping Copilot setup" >&2
fi
# other apps
link "$PWD"/.editorconfig ~/.editorconfig
link "$PWD"/hammerspoon/init.lua ~/.hammerspoon/init.lua
if [ -f "$PWD"/hammerspoon/apps."$host".lua ]; then
link "$PWD"/hammerspoon/apps."$host".lua ~/.hammerspoon/apps.lua
else
warn "No hammerspoon/apps.$host.lua, skipping app hotkeys."
fi
link "$PWD"/git/config ~/.config/git/config
link "$PWD"/git/gitignore ~/.config/git/ignore
link "$PWD"/gh/config.yml ~/.config/gh/config.yml
for ext in "$PWD"/gh/extensions/*; do
link "$ext" ~/.local/share/gh/extensions/"$(basename "$ext")"
done
link "$PWD"/gh-dash/config.yml ~/.config/gh-dash/config.yml
link "$PWD"/fd/ignore ~/.config/fd/ignore
link "$PWD"/direnv ~/.config/direnv
link "$PWD"/prowl ~/.config/prowl
link "$PWD"/copilot/copilot-instructions.md ~/.copilot/copilot-instructions.md
link "$PWD"/copilot/lsp-config.json ~/.copilot/lsp-config.json
link "$PWD"/copilot/mcp-config.json ~/.copilot/mcp-config.json
if [[ $OSTYPE == 'darwin'* ]]; then
if [ -f "$PWD"/Brewfile."$host" ]; then
brew cleanup --scrub --prune 0
info "Installing packages from Brewfile.$host - may ask for your password"
# Keep brew's "Installing X" lines (they explain any password prompt), but
# drop already-installed entries and mas' Spotlight indexing noise. awk
# always exits 0, so pipefail still reports brew's own failures.
brew bundle --file="$PWD"/Brewfile."$host" 2>&1 |
awk 'NF && !/^Using / && !/indexed in Spotlight|Indexing now|MAS_NO_AUTO_INDEX/'
else
warn "No Brewfile.$host, skipping brew bundle."
fi
fi
# Rust components are managed by rustup so they match the active toolchain.
rustup component add rust-analyzer rust-src rustfmt clippy &>/dev/null ||
warn "Could not add rust components (is rustup set up?)"
# Fish setup
if ! grep -q fish /etc/shells; then
info "Adding $(which fish) to /etc/shells - will ask sudo password"
which fish | sudo -p "Password for %u (needed to write to /etc/shells): " tee -a /etc/shells
fi
if ! finger "$USER" | grep -q 'Shell: .*fish'; then
info "Setting $(which fish) as the default shell - will ask user password"
chsh -s "$(which fish)"
fi
success "All done!"