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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
|
use Rex -feature => [ '1.14', 'exec_autodie' ];
use Rex::Logger;
our $HOME = $ENV{HOME};
# In a public Git rapository.
our $DOT = "$HOME/git/dotfiles";
# In a private Git repository.
our $DOT_PRIVATE = "$HOME/git/conf_private/dotfiles";
sub ensure_dir {
my ( $src_glob, $dst_dir, $file_mode ) = @_;
Rex::Logger::info("Ensure dir glob $src_glob");
file $dst_dir,
ensure => 'directory',
mode => '0700';
file "$dst_dir/" . basename($_),
ensure => 'present',
source => $_,
mode => $file_mode // '0640'
for glob $src_glob;
}
sub ensure_file {
my ( $src_file, $dst_file, $file_mode ) = @_;
file $dst_file,
ensure => 'present',
source => $src_file,
mode => $file_mode // '0640';
}
sub ensure {
my ( $src, $dst, $mode ) = @_;
( $dst =~ /\/$/ ? \&ensure_dir : \&ensure_file )->( $src, $dst, $mode );
}
desc 'Install packages on Termux';
task 'pkg_termux', sub {
my @pkgs = qw/
ack-grep
ctags
fzf
golang
htop
make
nodejs
ripgrep
rsync
ruby
starship
tig
/;
for my $pkg (@pkgs) {
Rex::Logger::info("Installing package $pkg");
pkg $pkg, ensure => 'installed';
}
};
desc 'Install packages on FreeBSD';
task 'pkg_freebsd', sub {
my @pkgs = qw/
zoxide
dust
lazygit
taskwarrior
bat
ctags
fzf
gmake
go
gron
htop
lynx
node
p5-ack
ripgrep
tig
doas
tmux
/;
for my $pkg (@pkgs) {
Rex::Logger::info("Installing package $pkg");
pkg $pkg, ensure => 'installed';
}
};
desc 'Install packages on Fedora Linux';
task 'pkg_fedora', sub {
my @pkgs = qw/
opendoas
fd-find
nodejs-bash-language-server
fortune-mod
syncthing
ncdu
ack
fish
bat
ctags
fzf
golang
golang-x-tools-gopls
gpaste
gron
htop
java-latest-openjdk-devel
lynx
make
nodejs
perl-File-Slurp
procs
rakudo
Rex
ripgrep
ruby
strace
task2
tig
tmux
dialect
chromium
strawberry
gnumeric
sway-config-fedora
sway
waybar
zathura
/;
for my $pkg (@pkgs) {
Rex::Logger::info("Installing package $pkg");
pkg $pkg, ensure => 'installed';
}
};
desc 'Install ~/.config/helix';
task 'home_helix', sub { ensure "$DOT/helix/*" => "$HOME/.config/helix/" };
desc 'Install ~/.config/ghostty';
task 'home_ghostty', sub { ensure "$DOT/ghostty/*" => "$HOME/.config/ghostty/" };
desc 'Install ~/.config/hexai (Linux only)';
task 'home_hexai', sub {
if ( $^O eq 'linux' ) {
ensure "$DOT/hexai/*" => "$HOME/.config/hexai/";
}
else {
Rex::Logger::info( 'Skipping hexai configuration (not on Linux)', 'warn' );
}
};
desc 'Install ~/.config/lazygit';
task 'home_lazygit', sub { ensure "$DOT/lazygit/*" => "$HOME/.config/lazygit/" };
desc 'Install ~/.config/opencode';
task 'home_opencode', sub { ensure "$DOT/opencode/*" => "$HOME/.config/opencode/" };
desc 'Install prompt links for AI tools';
task 'home_prompts', sub {
if ( -d "$HOME/Notes/Prompts/commands" ) {
Rex::Logger::info("Installing prompt links");
my $ensure_symlink = sub {
my ( $source, $target, $label ) = @_;
if ( -l $target ) {
my $existing = readlink $target;
if ( defined $existing && $existing eq $source ) {
return;
}
CORE::unlink($target) or die "Could not replace $label symlink at $target: $!";
}
elsif ( -d $target ) {
my ($leaf) = $target =~ m{([^/]+)$};
my $nested = "$target/$leaf";
if ( -l $nested && readlink($nested) eq $source ) {
CORE::unlink($nested) or die "Could not remove nested $label symlink at $nested: $!";
rmdir $target or die "Could not remove legacy $label directory at $target: $!";
}
else {
die "Refusing to overwrite existing directory at $target while linking $label";
}
}
elsif ( -e $target ) {
die "Refusing to overwrite existing path at $target while linking $label";
}
symlink $source => $target or die "Could not create $label symlink ($source -> $target): $!";
};
# For most agents, commands and skills live under ~/.<tool>/{commands,skills}.
my @tool_dirs = ( '.cursor', '.claude', '.agents', '.opencode' );
for my $tool_dir (@tool_dirs) {
file "$HOME/$tool_dir" => ensure => 'directory', mode => '0750';
$ensure_symlink->( "$HOME/Notes/Prompts/commands", "$HOME/$tool_dir/commands", "$tool_dir commands" );
$ensure_symlink->( "$HOME/Notes/Prompts/skills", "$HOME/$tool_dir/skills", "$tool_dir skills" );
}
# Codex CLI custom slash commands are loaded from ~/.codex/prompts.
file "$HOME/.codex" => ensure => 'directory', mode => '0750';
$ensure_symlink->( "$HOME/Notes/Prompts/commands", "$HOME/.codex/prompts", ".codex prompts" );
}
else {
Rex::Logger::info("Not installing prompt links");
}
};
desc 'Install ~/scripts';
task 'home_scripts', sub { ensure "$DOT/scripts/*" => "$HOME/scripts/", '0750' };
desc 'Install ~/.ssh files';
task 'home_ssh', sub { ensure "$DOT/ssh/config" => "$HOME/.ssh/config", '0600' };
desc 'Install BASH configuration';
task 'home_bash', sub {
ensure "$DOT/bash/bash_profile" => "$HOME/.bash_profile";
ensure "$DOT/bash/bashrc" => "$HOME/.bashrc";
};
desc 'Install ZSH configuration';
task 'home_zsh', sub {
if ( $^O eq 'darwin' ) {
ensure "$DOT/zsh/zshrc" => "$HOME/.zshrc";
}
else {
Rex::Logger::info( 'Skipping ZSH configuration (not on macOS)', 'warn' );
}
};
desc 'Install fish configuration';
task 'home_fish', sub {
# ensure "$DOT/fish/conf.d/*" => "$HOME/.config/fish/conf.d/";
my $dest_dir = "$HOME/.config/fish/conf.d";
if ( !-l $dest_dir ) {
if ( -d $dest_dir ) {
rename $dest_dir, "$dest_dir.old" or die "Could not rename $dest_dir: $!";
}
symlink "$DOT/fish/conf.d" => $dest_dir or die "Could not create symlink: $!";
}
};
desc 'Install gitsyncer configuration';
task 'home_gitsyncer', sub {
my $dest_dir = "$HOME/.config/gitsyncer";
symlink "$DOT/gitsyncer/" => $dest_dir or die "Could not create symlink: $!";
};
sub isFileSymlink() {
my $file = shift;
return -l $file && -e $file;
}
desc 'Vale and proselint';
task 'home_vale', sub {
ensure "$DOT/vale.ini" => "$HOME/.vale.ini";
say 'Now you can run "vale sync"';
};
desc 'Install tmux configuration';
task 'home_tmux', sub {
ensure "$DOT/tmux/*" => "$HOME/.config/tmux/";
};
desc 'Install Sway configuration';
task 'home_sway', sub {
ensure "$DOT/sway/config.d/*" => "$HOME/.config/sway/config.d/";
ensure "$DOT/waybar/*" => "$HOME/.config/waybar/";
};
desc 'Install global git configuration';
task 'home_gitconfig', sub {
if ( $^O eq 'linux' ) {
my %config = (
'user.email' => 'paul@buetow.org',
'user.name' => 'Paul Buetow',
'init.defaultbranch' => 'main',
'core.editor' => 'hx',
'core.pager' => 'delta',
'delta.navigate' => 'true',
'delta.side-by-side' => 'true',
'delta.features' => 'side-by-side line-numbers decorations',
'commit.verbose' => 'true',
'interactive.difffilter' => 'delta --color-only',
'diff.tool' => 'difftastic',
'difftool.prompt' => 'false',
'difftool.difftastic.cmd' => 'difft $LOCAL $REMOTE',
);
for my $key ( sort keys %config ) {
Rex::Logger::info("Setting git config $key");
run "git config --global '$key' '$config{$key}'";
}
}
else {
Rex::Logger::info( 'Skipping git configuration (not on Linux)', 'warn' );
}
};
desc 'Install my signature';
task 'home_signature', sub {
ensure "$DOT/signature" => "$HOME/.signature";
};
desc 'Install my calendar files';
task 'home_calendar', sub {
unless ( -d $DOT_PRIVATE ) {
Rex::Logger::info( "$DOT_PRIVATE not there, skipping task", 'warn' );
}
else {
ensure "$DOT_PRIVATE/calendar/*" => "$HOME/.calendar/";
}
};
desc 'Install my Pipewire tuned for High-Res config';
task 'home_pipewire', sub {
file "$HOME/.config/pipewire" => ensure => 'directory',
mode => '0750';
ensure
"$DOT/pipewire/pipewire.conf" => "$HOME/.config/pipewire/pipewire.conf",
'0600';
};
desc 'Manage ~/QuickEdit directory and symlinks';
task 'home_quickedit', sub {
if ( $^O eq 'linux' || $^O eq 'freebsd' ) {
Rex::Logger::info('Setting up ~/QuickEdit');
file "$HOME/QuickEdit",
ensure => 'directory',
mode => '0700';
my %symlinks = (
'data' => "$HOME/data/",
'Documents' => "$HOME/Documents//",
'dotfiles' => "$HOME/git/dotfiles/",
'foo.zone-gemtext' => "$HOME/git/foo.zone-content/gemtext//",
'Notes' => "$HOME/Notes/",
'public-snippets' => "$HOME/git/conf/snippets//",
'worktime' => "$HOME/git/worktime/",
);
for my $name ( keys %symlinks ) {
my $link_path = "$HOME/QuickEdit/$name";
my $target = $symlinks{$name};
# Remove existing symlink if it points to a different target
if ( -l $link_path ) {
my $current_target = readlink($link_path);
if ( $current_target ne $target ) {
unlink $link_path or die "Could not remove $link_path: $!";
symlink $target => $link_path or die "Could not create symlink $link_path: $!";
}
}
elsif ( -e $link_path ) {
Rex::Logger::info( "$link_path exists but is not a symlink, skipping", 'warn' );
}
else {
symlink $target => $link_path or die "Could not create symlink $link_path: $!";
}
}
}
elsif ( $^O eq 'darwin' ) {
Rex::Logger::info('QuickEdit placeholder for macOS (not yet implemented)');
# TODO: Implement QuickEdit management for macOS
}
};
desc 'Install all my ~ files';
task 'home', sub {
require Rex::TaskList;
run_task $_ for Rex::TaskList->create()->get_all_tasks('^home_');
};
|