-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·221 lines (187 loc) · 6.25 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·221 lines (187 loc) · 6.25 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
#!/bin/sh
set -e
DOTFILES="$HOME/dotfiles"
SSH_KEY="$HOME/.ssh/id_rsa"
# ── Helpers ────────────────────────────────────────────────────────────────────
info() { printf ' \033[0;34m→\033[0m %s\n' "$1"; }
ok() { printf ' \033[0;32m✓\033[0m %s\n' "$1"; }
err() { printf ' \033[0;31m✗\033[0m %s\n' "$1" >&2; }
die() { err "$1"; exit 1; }
symlink() {
ln -sf "$1" "$2"
ok "symlinked $(basename "$2")"
}
require() {
command -v "$1" > /dev/null 2>&1 || die "$1 is required for this task"
}
# ── Tasks ──────────────────────────────────────────────────────────────────────
task_git() {
info "Setting up git..."
symlink "$DOTFILES/git/gitconfig" "$HOME/.gitconfig"
}
task_vim() {
info "Setting up vim..."
require vim
symlink "$DOTFILES/vim/vimrc" "$HOME/.vimrc"
if [ ! -d "$HOME/.vim" ]; then
symlink "$DOTFILES/vim/vim" "$HOME/.vim"
fi
mkdir -p "$DOTFILES/vim/vim/bundle"
if [ ! -d "$DOTFILES/vim/vim/bundle/Vundle.vim" ]; then
info "Cloning Vundle..."
git clone https://github.com/VundleVim/Vundle.vim.git "$DOTFILES/vim/vim/bundle/Vundle.vim"
fi
vim +PluginInstall +qall
ok "vim plugins installed"
}
task_zsh() {
info "Setting up zsh..."
symlink "$DOTFILES/zsh/zshrc" "$HOME/.zshrc"
}
task_tmux() {
info "Setting up tmux..."
symlink "$DOTFILES/tmux/tmux.conf" "$HOME/.tmux.conf"
}
task_ssh() {
info "Setting up SSH..."
mkdir -p "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
cp -f "$DOTFILES/ssh/config" "$HOME/.ssh/config"
ok "SSH config copied"
if [ ! -f "$SSH_KEY" ]; then
ssh-keygen -t ed25519 -f "$SSH_KEY"
ok "SSH key generated"
fi
}
task_mutt() {
info "Setting up mutt..."
symlink "$DOTFILES/mutt/muttrc" "$HOME/.muttrc"
}
task_isync() {
info "Setting up isync..."
symlink "$DOTFILES/isync/mbsyncrc" "$HOME/.mbsyncrc"
mkdir -p "$HOME/Mail/fastmail"
}
task_zed() {
info "Setting up Zed..."
mkdir -p "$HOME/.config/zed"
symlink "$DOTFILES/zed/settings.json" "$HOME/.config/zed/settings.json"
}
task_claude() {
info "Setting up Claude Code..."
mkdir -p "$HOME/.claude"
symlink "$DOTFILES/claude/CLAUDE.md" "$HOME/.claude/CLAUDE.md"
}
task_vdirsyncer() {
info "Setting up vdirsyncer..."
mkdir -p "$HOME/.vdirsyncer/status"
mkdir -p "$HOME/.contacts/fastmail"
mkdir -p "$HOME/.calendars/fastmail"
symlink "$DOTFILES/vdirsyncer/config" "$HOME/.vdirsyncer/config"
ok "run 'vdirsyncer discover' then 'vdirsyncer sync' to populate"
}
task_brew() {
info "Setting up Homebrew..."
if [ "$(uname)" != "Darwin" ]; then
err "Homebrew is only supported on macOS — skipping"
return
fi
if command -v brew > /dev/null 2>&1; then
ok "Homebrew already installed"
return
fi
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
ok "Homebrew installed"
}
task_ansible_vm() {
info "Running Ansible for VM..."
require ansible
ansible-playbook -K -i "localhost," -c local "$DOTFILES/ansible/dev-vm.yml"
ok "Ansible VM playbook complete"
}
task_ansible_laptop() {
info "Running Ansible for laptop..."
require ansible
ansible-playbook -K -i "localhost," -c local "$DOTFILES/ansible/dev-laptop.yml"
ok "Ansible laptop playbook complete"
}
task_clean() {
info "Cleaning up symlinks and bundles..."
rm -f "$HOME/.gitconfig" "$HOME/.vimrc" "$HOME/.zshrc" "$HOME/.tmux.conf" "$HOME/.muttrc" "$HOME/.config/zed/settings.json" "$HOME/.claude/CLAUDE.md"
rm -rf "$HOME/.vim"
rm -rf "$DOTFILES/vim/vim/bundle"
ok "cleaned"
}
# ── Bundles ────────────────────────────────────────────────────────────────────
bundle_dev_vm() {
task_git
task_vim
task_ssh
}
bundle_dev() {
task_brew
task_git
task_vim
task_zsh
task_tmux
task_ssh
task_zed
task_claude
}
bundle_mail() {
info "Setting up mail..."
if command -v brew > /dev/null 2>&1; then
brew install isync vdirsyncer mutt
fi
task_mutt
task_isync
task_vdirsyncer
}
# ── Help & Dispatch ────────────────────────────────────────────────────────────
usage() {
cat <<EOF
Usage: ./install.sh <command>
Bundles
dev-vm Git, vim, and SSH setup
dev Git, vim, zsh, tmux, SSH, and Zed setup
mail Install and configure mutt, isync, and vdirsyncer
Ansible
ansible-vm Run Ansible install playbook for dev VMs
ansible-laptop Run Ansible install playbook for laptops
Tasks
brew Install Homebrew (macOS only)
git Symlink gitconfig
vim Symlink vimrc, install Vundle and plugins
zsh Symlink zshrc
tmux Symlink tmux.conf
ssh Copy SSH config, generate key if missing
zed Symlink Zed settings.json
claude Symlink Claude Code CLAUDE.md
Mail
mutt Symlink muttrc
isync Symlink mbsyncrc, create mail directories
vdirsyncer Symlink vdirsyncer config, create contact/calendar directories
Utilities
clean Remove all symlinks and vim bundles
EOF
}
case "${1:-}" in
dev-vm) bundle_dev_vm ;;
dev) bundle_dev ;;
mail) bundle_mail ;;
ansible-vm) task_ansible_vm ;;
ansible-laptop) task_ansible_laptop ;;
brew) task_brew ;;
git) task_git ;;
vim) task_vim ;;
zsh) task_zsh ;;
tmux) task_tmux ;;
ssh) task_ssh ;;
mutt) task_mutt ;;
isync) task_isync ;;
vdirsyncer) task_vdirsyncer ;;
zed) task_zed ;;
claude) task_claude ;;
clean) task_clean ;;
*) usage ;;
esac