-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
268 lines (206 loc) · 7.34 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
#!/usr/bin/env just --justfile
export SRC_DIR := "/Users/syphar/src"
default:
just --list
daily-update:
git pull # to allow SSH key access in 1p, once, so later steps can use it
just heroku-cli
just gcloud-cli
update_cached_heroku_apps
just update-homebrew
just update-luarocks
just update-pipx
just update-generated-autocompletes
just update-cached-pypi-package-list
just update-rust
just npm-upgrade
just kill-leftover-background-processes
just tldr-update
gh extension upgrade --all
## bat cache
bat cache --build
just mackup
just update-fish
just update-vim
just update-venv $SRC_DIR/neovim_env/venv/
# github packages downloads
./download_github_release.sh marksman artempyanykh/marksman marksman-macos
./download_github_release.sh tuc riquito/tuc tuc-macos-amd64
# update tmux plugins
./find_repos.sh "$HOME/.tmux/plugins" | xargs -n 1 sh -c 'just update-git-repo $0 || exit 255'
just update-git-repos
just update-git-worktrees
update-git-repos:
./find_repos.sh $SRC_DIR | xargs -n 1 sh -c 'just update-git-repo $0 || exit 255'
update-git-worktrees:
./find_worktrees.sh $SRC_DIR | xargs -n 1 sh -c 'just update-git-worktree $0 || exit 255'
update-generated-autocompletes:
poetry completions fish > ~/.config/fish/completions/poetry.fish
poe _fish_completion > ~/.config/fish/completions/poe.fish
_DSLR_COMPLETE=fish_source dslr > ~/.config/fish/completions/dslr.fish
mackup:
pip install --upgrade -r requirements.txt
## mackup
mackup restore --force
mackup backup
# copy mackup files to dotfiles
./mackup_dotfiles.py
kill-leftover-background-processes:
## cleanup dmypy processes
pkill -f dmypy || echo "nothing to kill"
## cleanup pylsp processes
pkill -f pylsp || echo "nothing to kill"
tldr-update:
## tldr update
tldr --update || echo "failed, but ignore for now"
gcloud-cli:
gcloud components update --quiet
heroku-cli:
## heroku login, so we can fetch from heroku remotes later
heroku whoami || heroku login
## update the Heroku CLI
heroku update
## try to update the autocomplete cache
heroku autocomplete zsh
update-homebrew:
brew update && brew upgrade && brew upgrade --cask
## install missing packages
brew bundle --no-upgrade --no-lock --quiet 1>/dev/null
## delete packages not in dump
brew bundle cleanup -f
## cleanup
brew cleanup -s
update-luarocks:
## luarocks packages
-xargs -n 1 luarocks install < luarocks_list.txt
## luarocks packages for lua 5.1, for neovim
-xargs -n 1 luarocks install --lua-version 5.1 < luarocks_list.txt
update-pipx:
## install/update pipx packages
-xargs -n 1 pipx install --include-deps < pipx_list.txt 1>/dev/null
pipx reinstall-all
pipx inject python-lsp-server pylsp-mypy rope
pipx inject httpie httpie-ntlm
pipx inject httpie 'urllib3<2' # https://github.com/httpie/httpie/issues/1499
pipx inject poetry poetry-dynamic-versioning
pipx inject ipython rich requests
pipx inject dslr psycopg2-binary
update-vim:
rm -f ~/.local/state/nvim/*.log
nvim --headless '+Lazy! sync' +qa
npm-upgrade:
#!/usr/bin/env bash
set -euxo pipefail
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f2)
do
npm -g install "$package"
done
xargs -n 1 npm install -g < global_npm_packages.txt
cargo-sweep REPO:
cd {{ REPO }} && \
cargo sweep --time 30 && \
cargo sweep --installed
update-cached-pypi-package-list:
# regex /ggrep via https://unix.stackexchange.com/a/13472/388999
curl --compressed -s "https://pypi.org/simple/" | ggrep -oP '(?<=/simple/)[^/]+(?=/)' > ~/.cache/pypi_packages.txt
update-rust:
rustup update
cargo install-update -a
-/bin/cat cargo_install.txt | tr '\n' '\0' | xargs -0 -n1 cargo install
cargo-install:
#!/usr/bin/env fish
for line in (cat cargo_install.txt)
eval (cargo install $line)
end
update-fish: clean-fish
# update fisher
fish -c "fisher update"
clean-fish:
rm -f ~/.config/fish/fishd.tmp.*
rm -f ~/.config/fish/fish_variables*conflicted*
update-venv VENV:
{{ VENV }}/bin/pip freeze | \
grep = | \
cut -d = -f 1 | \
xargs {{ VENV }}/bin/pip install -U
install-custom-rust-binary REPO BINARY_NAME:
cd {{ REPO }} && cargo build --release
rm -f $HOME/bin/{{ BINARY_NAME }}
mv {{ REPO }}/target/release/{{ BINARY_NAME }} $HOME/bin/{{ BINARY_NAME }}
update-git-repo REPO:
#!/bin/bash
set -euo pipefail
if [ -e "{{ REPO }}/Cargo.toml" ] && [ -d "{{ REPO }}/target" ]; then
just cargo-sweep "{{ REPO }}"
fi
cd "{{ REPO }}"
~/bin/rebuild_tags.sh
if [ -f "{{ REPO }}/.pre-commit-config.yaml" ]; then
if [ ! -f "{{ REPO }}/.git/hooks/pre-commit" ]; then
echo "pre-commit not found, installing..."
pre-commit install
else
echo "pre-commit found"
fi
fi
if [ -f "{{ REPO }}/.git-blame-ignore-revs" ]; then
git config blame.ignoreRevsFile .git-blame-ignore-revs
fi
ln -s $HOME/src/dotfiles/git-hooks/* "{{ REPO }}/.git/hooks" || echo "already exists"
git gc
if [ -n "$(git remote)" ];
then
git fetch --all --recurse-submodules=yes --prune --force
git fetch --all --prune --tags --force
git merge --ff-only || echo "merge failed, but ok"
git branch -v | grep "\[gone\]" | awk '{print $1}' | xargs git branch -D || echo "failed, but ok"
fi
update-git-worktree REPO:
#!/bin/bash
set -euo pipefail
cd "{{ REPO }}"
~/bin/rebuild_tags.sh
if [ -n "$(git remote)" ];
then
git merge --ff-only || echo "merge failed, but ok"
fi
clear-disk-space:
just clear-thermondo-backups
just clear-logs
just clear-docker
just clear-cargo-cache
just clear-dev-environments
just clear-caches
just clear-rust-target-directories
just clear-docsrs-dev
clear-thermondo-backups:
fd --type f --full-path --no-ignore ".*/sql/backup/.*\.sql" "$SRC_DIR/thermondo/" --exec rm -rf {}
clear-logs:
rm -rf /usr/local/var/log/*
clear-docker:
docker container prune -f
docker image prune -a -f
docker builder prune -a -f
docker volume prune -f --all
docker volume prune -f --all
clear-cargo-cache:
cargo cache --autoclean
clear-rust-target-directories:
# clear target directories
fd Cargo.toml "$SRC_DIR" --exec rm -rf \{//\}/target
# remove cargo cache
rm -rf ~/.cargo/cache
# remove custom toolchains
rustup toolchain list | grep -v nightly-aarch64-apple-darwin | grep -v stable-aarch64-apple-darwin | xargs -n 1 rustup toolchain remove
clear-caches:
rm -rf ~/Library/Caches/*
rm -rf ~/Library/Developer/CoreSimulator/Caches/*
rm -rf ~/.npm/_cacache
rm -rf ~/.cache/
clear-dev-environments:
fd --type d --no-ignore --hidden --prune "^\.direnv$" "$SRC_DIR" --exec rm -rf {}
fd --type d --no-ignore --hidden --prune "^\.tox$" "$SRC_DIR" --exec rm -rf {}
fd --type d --no-ignore --prune node_modules "$SRC_DIR" --exec rm -rf {}
clear-docsrs-dev:
fd --type d --no-ignore --hidden --prune "\.rustwide-docker" "$SRC_DIR/rust-lang/" --exec rm -rf {}
fd --type d --no-ignore --hidden --prune "ignored" "$SRC_DIR/rust-lang/" --exec rm -rf {}