-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
465 lines (374 loc) · 14 KB
/
justfile
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
set dotenv-load
export PROJECT_ROOT := justfile_directory()
export HOMEBREW_NO_AUTO_UPDATE := "1"
default:
just --list
@echo '💡 To initialize just aliases: source alias.sh'
new +PARAMS:
./new.sh {{PARAMS}}
build:
./build.sh
dev:
./dev.sh
lize:
./lize.sh
fize:
./fize.py
chk:
./chk.sh
thm:
./thm.sh
prep-bib:
@echo "pyenv shell 3.11"
@echo "pip3 install bibtexparser"
bib:
./bib.sh
glsl SOURCE:
mkdir -p output/shader/
cp -f {{SOURCE}} output/shader/
css SOURCE:
bunx --bun lightningcss-cli --minify --bundle --targets '>= 0.25%' {{SOURCE}} -o output/{{file_name(SOURCE)}}
# bunx postcss -o output/{{file_name(SOURCE)}} {{SOURCE}}
js SOURCE:
bun run bun_build.js {{SOURCE}}
forest:
opam exec -- forester build # 2>&1 > build/forester.log # --dev
copy SOURCE:
-rm output/{{file_name(SOURCE)}} > /dev/null 2>&1
cp -f {{SOURCE}} output/
typ SOURCE:
mkdir -p output/typst/
cp -f {{SOURCE}} output/typst/
penrose SOURCE:
mkdir -p output/penrose/
cp -f {{SOURCE}} output/penrose/
envs:
#!/usr/bin/env bash
echo "PROJECT_ROOT: $PROJECT_ROOT"
install-shellcheck:
brew install shellcheck
run-shellcheck:
shellcheck *.sh
prep-term: prep-kitty
which zsh || brew install zsh
which nvim || brew install neovim
which lazygit || brew install lazygit
which yq || brew install yq
which gh || brew install gh
@echo "Remember to run: gh auth login"
@echo "And possibly: gh auth refresh -s read:project"
which fzf || brew install fzf
which yazi || brew install yazi
which nnn || brew install nnn
which stylua || brew install stylua
which sd || brew install sd
which dua || brew install dua-cli
which bat || brew install bat
which eza || brew install eza
which rg || brew install ripgrep
which rip || brew install rm-improved
which luarocks || brew install luarocks
# luarocks --local --lua-version=5.1 install magick
which starship || brew install starship
which zoxide || brew install zoxide
which magick ||brew install imagemagick
just add-zrc 'eval "$(zoxide init zsh)"'
just add-zrc 'eval "$(starship init zsh)"'
which progress || brew install progress
which 7z || brew install sevenzip
which ffmpeg || brew install ffmpeg
prep-alacritty:
#!/usr/bin/env bash
# Install FiraCode Nerd Font from https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/FiraCode.zip
# After installation, run: fc-cache -f -v
# Default Mac terminal cannot support true color
which alacritty || brew install --cask alacritty
# configure alacritty
# https://alacritty.org/config-alacritty.html
cp .alacritty.toml ~/.alacritty.toml
[macos]
prep-kitty: && sync-kitty
which kitty || brew install --cask kitty
[linux]
prep-kitty:
# no op for now
# curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin
@sync-kitty:
# configure kitty
# https://sw.kovidgoyal.net/kitty/conf.html
mkdir -p ~/.config/kitty
cp -f kitty.conf ~/.config/kitty/kitty.conf
cp -f kitty_session.conf ~/.config/kitty/kitty_session.conf
[macos]
prep-warp:
#!/usr/bin/env bash
if [ ! -d "/Applications/Warp.app" ]; then
brew install --cask warp
echo "CMD+, then search for terminal, specify External: Osx Exec to Warp.app"
fi
stylua:
stylua *.lua
sync-nvim: stylua
#!/usr/bin/env bash
mkdir -p ~/.config/nvim
cp -f init.lua ~/.config/nvim/init.lua
sync-plugins: stylua
mkdir -p ~/.config/nvim/lua/plugins/
cp -f uts-plugins.lua ~/.config/nvim/lua/plugins/spec.lua
sync-lvim: stylua sync-nvim sync-kitty
mkdir -p ~/.config/lvim
cp -f init.lua ~/.config/lvim/nvim-init.lua
cp -f uts-plugins.lua ~/.config/lvim/uts-plugins.lua
cp -f config.lua ~/.config/lvim/config.lua
sync-lazyvim: stylua sync-plugins
mkdir -p ~/.config/lazyvim
cp -f init.lua ~/.config/lazyvim/lua/config/options.lua
# cp -f lazyvim-init.lua ~/.config/lazyvim/lazyvim-init.lua
sync-chad: stylua sync-plugins
mkdir -p ~/.config/nvchad/
cp -f init.lua ~/.config/nvchad/nvim-init.lua
cp -f lazyvim-init.lua ~/.config/nvchad/nvchad-init.lua
prep-nvim: prep-term
#!/usr/bin/env bash
which nvim || brew install neovim
# rip ~/.config/nvim
# git clone https://github.com/ntk148v/neovim-config.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim
@nvim PROJ="forest" *PARAMS="": sync-nvim
#!/usr/bin/env bash
cd ~/projects/{{PROJ}} && nvim {{PARAMS}}
prep-lvim: prep-term prep-nvim
#!/usr/bin/env bash
# rip ~/.cache/lvim ~/.bun/install ~/.local/share/lunarvim ~/.config/lvim/
# bun upgrade
yes|bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/master/utils/installer/install.sh)
just add-zrc 'export PATH=$HOME/.local/bin:$PATH'
just sync-lvim
(cd ~/.config/lvim/ && lvim --headless +'lua require("lvim.utils").generate_settings()' +qa && sort -o lv-settings.lua{,} )
echo
echo "Use lvim to start LunarVim"
@lvim PROJ="forest" *PARAMS="": sync-lvim
#!/usr/bin/env bash
cd ~/projects/{{PROJ}} && lvim {{PARAMS}}
prep-lazyvim:
#!/usr/bin/env bash
if [ -d ~/.config/lazyvim ]; then
(cd ~/.config/lazyvim && git pull)
else
git clone https://github.com/LazyVim/starter ~/.config/lazyvim
fi
@lazyvim PROJ="forest": sync-lazyvim
#!/usr/bin/env bash
cd ~/projects/{{PROJ}} && nvim --cmd 'set runtimepath+=~/.config/lazyvim/' --cmd 'lua package.path = package.path .. ";{{home_directory()}}/.config/lazyvim/lua/?.lua"' -u ~/.config/lazyvim/init.lua
prep-chad:
#!/usr/bin/env bash
if [ -d ~/.config/nvchad ]; then
(cd ~/.config/nvchad && git pull)
else
git clone https://github.com/NvChad/starter ~/.config/nvchad
fi
@chad PROJ="forest": sync-chad
#!/usr/bin/env bash
cd ~/projects/{{PROJ}} && nvim --cmd 'set runtimepath+=~/.config/nvchad/' --cmd 'lua package.path = package.path .. ";{{home_directory()}}/.config/nvchad/lua/?.lua"' -u ~/.config/nvchad/nvchad-init.lua
yazi DIR="{{HOME}}/projects":
#!/usr/bin/env bash
EDITOR=lvim yazi {{DIR}}
# https://github.com/astral-sh/uv
[unix]
prep-uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
[windows]
prep-uv:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
prep-py:
uv python install 3.11
uv venv --python 3.11 --seed
prep-sbar:
#!/usr/bin/env bash
curl -L https://raw.githubusercontent.com/FelixKratz/dotfiles/master/install_sketchybar.sh | sh
mkdir -p ~/.config/sketchybar/plugins
cp /opt/homebrew/opt/sketchybar/share/sketchybar/examples/sketchybarrc ~/.config/sketchybar/sketchybarrc
cp -r /opt/homebrew/opt/sketchybar/share/sketchybar/examples/plugins/ ~/.config/sketchybar/plugins/
chmod +x ~/.config/sketchybar/plugins/*
brew services restart felixkratz/formulae/sketchybar
# Inspired by https://github.com/FelixKratz/dotfiles
dotfiletmpdir := "/tmp/dotfiles-" + choose('8', HEX)
prep-dotfiles-tmp:
git clone https://github.com/FelixKratz/dotfiles {{dotfiletmpdir}}
config-sbar: prep-dotfiles-tmp
#!/usr/bin/env bash
rm -rf ~/.config/sketchybar
cp -r {{dotfiletmpdir}}/.config/sketchybar ~/.config/
rm -rf {{dotfiletmpdir}}
brew services restart felixkratz/formulae/sketchybar
sbar:
brew services restart felixkratz/formulae/sketchybar
prep-tile: prep-amethyst
prep-skhd: prep-dotfiles-tmp
brew install koekeishiya/formulae/skhd
rm -rf ~/.config/skhd
cp -r {{dotfiletmpdir}}/.config/skhd ~/.config/
skhd --start-service
prep-yabai: prep-dotfiles-tmp prep-skhd
brew install koekeishiya/formulae/yabai
rm -rf ~/.config/yabai
cp -r {{dotfiletmpdir}}/.config/yabai ~/.config/
yabai --start-service
no-yabai:
yabai --stop-service
skhd --stop-service
prep-amethyst:
brew install --cask amethyst
cp -f .amethyst.yml ~/.amethyst.yml
prep-monit:
#!/usr/bin/env bash
which btop || brew install btop
# which glances || brew install glances
if [ "$(uname)" == "Darwin" ]; then
if [ "$(uname -m)" == "aarch64" ]; then
which macmon || brew install vladkens/tap/macmon
# which neoasitop || (brew tap op06072/neoasitop && brew install neoasitop)
else
echo "No GPU monit tools found yet"
fi
fi
rec:
uvx asciinema rec
add-zrc LINE:
grep -F '{{LINE}}' ~/.zshrc|| echo '{{LINE}}' >> ~/.zshrc
add-brc LINE:
grep -F '{{LINE}}' ~/.bashrc || echo '{{LINE}}' >> ~/.bashrc
prep-centos:
yes|sudo yum groupinstall 'Development Tools'
yes|sudo yum install procps-ng curl file git
yes|/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
just add-zrc 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'
yes|sudo yum install util-linux-user
just chsh
just prep-term
which node || brew install node
yes|sudo yum install gtk2-devel openssl-devel
chsh:
# chsh -s `chsh -l|grep zsh|head -1` `whoami`
# chsh -s `which zsh` `whoami`
prep-ubuntu:
sudo apt update
sudo apt install -y build-essential curl file git
yes|/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
just add-zrc 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'
just add-brc 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'
sudo apt install -y zsh
# prep-act: prep-term
# #!/usr/bin/env bash
# which act || brew install act
# act:
# ./act.sh
mk-act:
sudo docker run -d --name act-dev -v{{justfile_directory()}}:/root/projects/forest -p 127.0.0.1:1214:1214 ghcr.io/catthehacker/ubuntu:act-latest bash -c 'sleep infinity'
run-act CMD="bash" OPTS="-it":
sudo docker exec {{OPTS}} -w /root/projects/forest act-dev {{CMD}}
# manually run bootstrp-ubuntu first, or we won't even have just
prep-act:
# for brew and zsh
just prep-ubuntu
just prep-act-in-zsh
prep-act-in-zsh:
#!/usr/bin/env zsh
source ~/.zshrc
just prep-term
just prep-rust
just prep-lvim-in-zsh
echo 'To start lvim in server mode, run: just lv-remote'
echo 'Then from outside the container, run: just lv-local'
prep-lvim-in-zsh:
#!/usr/bin/env zsh
just prep-lvim
mk-rp:
sudo docker run -d --privileged --name rp-dev -v{{justfile_directory()}}:/root/projects/forest runpod/pytorch:2.2.1-py3.10-cuda12.1.1-devel-ubuntu22.04 bash -c 'sleep infinity'
run-rp:
sudo docker exec -it -w /root/projects/forest rp-dev bash
# copy and paste to run, because we have no just at this point
bootstrp-ubuntu:
#!/usr/bin/env bash
apt update
apt install -y build-essential curl file git sudo
wget -qO - 'https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub' | gpg --dearmor | sudo tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1> /dev/null
echo "deb [arch=all,$(dpkg --print-architecture) signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr $(lsb_release -cs)" | sudo tee /etc/apt/sources.list.d/prebuilt-mpr.list
sudo apt update
sudo apt install -y just
prep-chisel:
#!/usr/bin/env bash
which chisel || (curl https://i.jpillora.com/chisel! | bash)
# default ports are ordered so it's clear that local nvim -> local 1212 -> mid 1213 -> remote nvim 1214
# authenticated by environment variable AUTH user:pass
cs-remote PORT="1213":
chisel server -v --port {{PORT}}
cs_mid := env("CS_MID", "localhost:1213")
cs-local MID=cs_mid LOCAL="1212" TARGET="1214":
chisel client -v http://{{MID}} {{LOCAL}}:{{TARGET}}
nv-remote PROJ="forest" PORT="1214":
just nvim {{PROJ}} --embed --listen localhost:{{PORT}}
nv-local PROJ="forest" PORT="1212":
just nvim {{PROJ}} --server localhost:{{PORT}} --remote-ui
# an alternative is use local on CentOS and remote on Ubuntu in docker, no chisel needed, just docekr port mapping
lv-remote PROJ="forest" PORT="1214":
#!/usr/bin/env zsh
just lvim {{PROJ}} --embed --listen 0.0.0.0:{{PORT}}
lv-local PROJ="forest" PORT="1214":
#!/usr/bin/env zsh
just lvim {{PROJ}} --server localhost:{{PORT}} --remote-ui
prep-rust:
#!/usr/bin/env bash
set -e
which cargo || (
(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly) &&
(just add-zrc '. $HOME/.cargo/env' && echo 'Run: . $HOME/.cargo/env')
)
. $HOME/.cargo/env
which cargo-binstall || cargo install cargo-binstall
@prep-sync-dir-tools: prep-rust
which jw || (yes|cargo binstall jw)
which rusync || (yes|cargo binstall rusync)
which rip || (yes|cargo binstall rm-improved)
sync-dirs SRC DST:
@just rusync-dirs {{SRC}} {{DST}}
@just check-dirs {{SRC}} {{DST}}
rusync-dirs SRC DST: prep-sync-dir-tools
#!/usr/bin/env bash
echo "🚀 Initiating sync..."
rusync {{SRC}} {{DST}}
# using this would trigger mismatch
# rusync --err-list {{DST}}/.rusync.err.log {{SRC}} {{DST}}
check-dirs SRC DST:
#!/usr/bin/env bash
echo "🔍 Checking hash..."
date
(cd {{SRC}} && jw -c . > .hash.jw) && echo "1. source hashed: `date`"
(cd {{DST}} && jw -c . > .hash.jw) && echo "2. destination hashed: `date`"
MISMATCH=`jw -D {{SRC}}/.hash.jw {{DST}}/.hash.jw`
if [ -z "$MISMATCH" ]; then
echo "✅ Perfect match"
else
echo "❌ Mismatch detected"
if [ ${#MISMATCH} -gt 1000 ]; then
echo "$MISMATCH"|less
else
echo "$MISMATCH"
fi
fi
# keep them both, avoid recalculation of hash
# only remove hash.jw file from the source
# rip {{SRC}}/.hash.jw
# rip {{DST}}/.hash.jw
echo "Open {{DST}}/.hash.jw to inspect"
prep-llm:
which aichat || brew install aichat
which cortex || echo "Visit https://cortex.so/docs/installation to download and install cortex"
# docker pull dockerproxy.net/paulgauthier/aider-full
cp -f aider /usr/local/bin
llm-proxy *PARAMS:
#!/usr/bin/env bash
# uvx --python 3.11 --from 'litellm[proxy]' litellm {{PARAMS}}
aichat --serve 0.0.0.0:4000
# a zsh that inherits .env
zsh:
zsh