-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc.Darwin.after.sh
447 lines (406 loc) · 15.3 KB
/
zshrc.Darwin.after.sh
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
#!/usr/bin/env zsh
# source "$DOTFILES/bashrc.sh"
source "$DOTFILES/modules/color.sh"
source "$DOTFILES/modules/dotwatch.sh"
function binstall() {
local base="$(basename "$1")"
[[ ! -f "$base" ]] && echo "🔴 !file -> '$base'" && return 1
local target="$(readlink -f "${2:-"$HOMEBREW_PREFIX/bin"}")"
[[ ! -d "$target" ]] && echo "🔴 !directory -> '$target'" && return 1
unquarantine "$base"
cp -f -t "$target" "$base"
chown $(id -un):admin "$target/$base"
chmod 755 "$target/$base"
rd "$base"
}
function ldd() {
local v && for v in "$@"; do
dyldinfo -dylibs "$v" | lscolors
done
}
alias awdown="killall -INT aw-qt aw-watcher-afk aw-server System\ Events FolderActionsDispatcher"
alias awup="pgrep aw- &>/dev/null && awdown && sleep 3; init.daemonize /Applications/ActivityWatch.app/Contents/MacOS/aw-qt"
alias pgup="killall postgres && sleep 1; init.daemonize postgres -D /opt/homebrew/var/postgresql@15 && sleep 1 && procs postgres"
# alias re="(cd ~/Projects/userscripts && just run src/serve.ts)"
# alias ii="iina"
# alias vlc="vlc --verbose 2"
# alias mpv="mpv --msg-module --msg-level=all=status --no-audio-display"
alias .mpv-debug-input="mpv --input-test --input-cursor=no --force-window --idle"
# function .mpv.debug.input() {
# bhr
# echo "█ mplayer-input.conf" && curl https://raw.githubusercontent.com/mpv-player/mpv/master/etc/mplayer-input.conf | sed 's/^#\b//' | bl config
# echo "█ input.conf" && curl https://raw.githubusercontent.com/mpv-player/mpv/master/etc/input.conf | sed 's/^#\b//' | bl config
# mpv --input-test --input-cursor=no --force-window --idle
# }
# alias dstore="find . -type f -name .DS_Store -print -delete"
alias dstore="fd -uu --type=file --glob '.DS_Store' --exec-batch rm -fv"
alias kextstat="kextstat -sort"
if [[ -x "$HOMEBREW_PREFIX/bin/scp" ]]; then
alias scp="/usr/bin/scp -4 -p -r"
# alias scp="scp -D $HOMEBREW_PREFIX/opt/openssh/libexec/sftp-server -4 -p -r"
fi
alias installer="installer -verbose"
alias pkginfo="installer -pkginfo -pkg"
alias pkgls="pkgutil --pkgs | sortt"
function pkgi() {
local v && for v in "$@"; do
echo && echo "🟡 $v"
pkgutil --pkg-info "$v" | bl yml
pkgutil --only-files --files "$v" | sed 's#^#/#' | sortt | lscolors
done
}
[[ -x "/Applications/FileMonitor.app/Contents/MacOS/FileMonitor" ]] && alias FileMonitor="/Applications/FileMonitor.app/Contents/MacOS/FileMonitor"
[[ -x "/Applications/DNSMonitor.app/Contents/MacOS/DNSMonitor" ]] && alias DNSMonitor="/Applications/DNSMonitor.app/Contents/MacOS/DNSMonitor"
[[ -x "/Applications/ProcessMonitor.app/Contents/MacOS/ProcessMonitor" ]] && alias ProcessMonitor="/Applications/ProcessMonitor.app/Contents/MacOS/ProcessMonitor"
alias .duti-cache="(lsregister -dump | rg --color=never -e '^uti:\s+(\S+)' -or '\$1' | sortt --unique) > $HOME/.cache/lsregister.duti.dump && wc --lines $HOME/.cache/lsregister.duti.dump"
alias .duti-ls="cat $HOME/.cache/lsregister.duti.dump"
function .duti-sublime() {
gc 'https://github.com/sublimehq/Packages'
rm 'AppleScript/AppleScript.sublime-syntax' 'C++/C++.sublime-settings' 'R/R Console.sublime-syntax'
local bundle_id="$(osascript -e 'id of app "Sublime Text"')"
rg --files-with-matches 'file_extensions' | while read i; do
echo && echo "🔴 $i 🔴"
cat "$i" | oq -i yaml -r '.file_extensions[]' | while read ii; do
echo && echo "🟡 $ii"
duti -x "$ii"
[[ -n "$ii" ]] && duti -s "$bundle_id" "$ii" all
done
done
}
# alias duti-sublime='gc https://github.com/sublimehq/Packages && rg --files-with-matches file_extensions | while read i; do echo; echo "🔴 $i"; cat "$i" | oq -i yaml -r ".file_extensions[]" | while read ii; do echo; echo "🟡 $ii"; duti -s com.sublimetext.3 "$ii" all; done; done'
# r --files-with-matches file_extensions | while read i; do echo; echo "🔴 $i"; cat "$i" | oq -i yaml -r '.file_extensions[]' | while read ii; do echo; echo "🟡 $ii"; duti -x "$ii"; done; done
# alias ssh="ssh -L 52698:localhost:52699"
# alias pbcopy="pbcopy -Prefer txt"
alias ppcopy="tr -d '\n' | pbcopy"
alias pwg="pwgen --ambiguous --num-passwords=1 16"
alias gpw="echo; pwg | tee /dev/tty | tr -d '\n' | pbcopy"
# alias gpw="echo; gpg --armor --gen-random 0 12 | tee /dev/tty | tr -d '\n' | pbcopy"
function kbb() {
if [[ -z "$1" ]]; then
mac-brightnessctl 0.01
else
mac-brightnessctl "$1"
fi
} && compdef kbb=mac-brightnessctl
alias hostsflush="sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder"
alias .hosts="sudo $EDITOR /etc/hosts && echo '$(echo $aliases[hostsflush])' && hostsflush"
alias .paths="sudo $EDITOR /etc/paths"
alias .profile="sudo $EDITOR /etc/.profile"
alias .alacritty="subl $DOTFILES/configs/alacritty.yml"
alias .gitconfig="subl $DOTFILES/configs/gitconfig"
alias .gitignore="subl $DOTFILES/configs/gitignore"
alias .gradle="subl $DOTFILES/configs/gradle.properties"
alias .prettierrc="subl $DOTFILES/configs/.prettierrc"
alias .starship="subl $DOTFILES/configs/starship.toml"
alias .npmrc="subl $DOTFILES/configs/.npmrc"
alias .ssh_config="subl $HOME/.ssh/config"
alias .known_hosts="subl $HOME/.ssh/known_hosts"
alias .rclone="subl $HOME/.config/rclone/rclone.conf"
alias .vlc="subl $HOME/Library/Preferences/org.videolan.vlc/vlcrc"
alias .h2o="subl $HOMEBREW_PREFIX/etc/h2o/h2o.conf"
alias .nginx="subl $HOMEBREW_PREFIX/etc/nginx/nginx.conf"
alias .lighttpd="subl $HOMEBREW_PREFIX/etc/lighttpd/lighttpd.conf"
alias .pfc="sudo $EDITOR /etc/pf.conf"
alias pfcat="cat /etc/pf.conf | sed -e '/^[ ]*#/d' -e '/^$/d' | bat --file-name=/etc/pf.conf -l py"
alias pfs="sudo pfctl -q -s info | head -n 1; sudo pfctl -q -s states"
alias pfsr="sudo pfctl -q -s rules | bat --style=grid -l py"
alias pfsa="sudo pfctl -q -s all"
alias pfd="sudo pfctl -q -d -F all; pfs"
alias pfu="sudo pfctl -q -d -F all || true; sudo pfctl -q -F all -e -f /etc/pf.conf; pfs"
alias wgs="sudo wg"
alias wgdown="sudo fd --base-directory /opt/homebrew/etc/wireguard -e conf -x wg-quick down '{.}' || true; echo; sudo wg"
# alias wgup="wgdown; echo; wg-quick up ivpn.ny; echo; sudo wg"
function wgup() {
wgdown
echo
wg-quick up ${1:-ivpn.ny}
echo
sudo wg
}
# alias wg-up="sudo launchctl load -w /Library/LaunchDaemons/com.wireguard.ivpn-ny.plist; sleep 1; echo; sudo wg; echo; pfs"
# function wg-up() {
# # [[ -z "$1" ]] && echo "🔴 WireGuard interface -> 'com.wireguard.$1.plist'" && return 1
# if [[ ! -e "/Library/LaunchDaemons/com.wireguard.$1.plist" ]]; then
# echo "🔴 '/Library/LaunchDaemons/com.wireguard.$1.plist' -> Not Found"
# return 1
# fi
# wg-down
# sudo launchctl load -w "/Library/LaunchDaemons/com.wireguard.$1.plist"
# sleep 1 && echo
# sudo wg && echo
# pfs
# }
# alias wg-down="sudo launchctl unload -w /Library/LaunchDaemons/com.wireguard.ivpn-ny.plist; sleep 1; echo; sudo wg; echo; pfd"
# function wg-down() {
# find /Library/LaunchDaemons -type f -name 'com.wireguard.*.plist' | while read i; do (
# # echo && echo "▶ $i" &&
# sudo launchctl unload -w "$i" 2> /dev/null
# ); done
# echo && sleep 1
# sudo wg
# pfd
# # local i && for i in /Library/LaunchDaemons/com.wireguard.*.plist; do (
# # echo && echo "▶ $i" && sudo launchctl unload -w "$i"
# # ); done
# }
alias gmls="genyshell -c 'devices list'; echo; VBoxManage list vms"
alias gmup="open -a player --args --vm-name"
alias ifcls="ifconfig -v -a -r"
alias lsapps="lsappinfo list | bat --style=grid -l ini"
alias restic-laptop="restic --verbose --repo rclone:drive:restic-laptop"
alias razer-up="open -a RzDeviceEngine && open -a RzUpdater"
alias razer-down="killit RzDeviceEngine && killit RzUpdater"
alias gmtool="gmtool --verbose"
alias voxel="echo; echo nj3nxCEBUX7BDDei; echo; telnet 192.168.1.1"
alias voxel-gost=" echo 'start-stop-daemon -S -b -x /root/gost -- -L=:11080'"
alias avr="curl --insecure 'https://192.168.2.119:10443/ajax/general/get_config?type=12' | oq -i xml -o yaml '{MainZone:.Information.Zone.MainZone,HDMISignalInfo:.Information.Video.HDMISignalInfo,HDMIMonitor1:.Information.Video.HDMIMonitor1,Audio:.Information.Audio}' | t2 | bl yml"
alias avr.device-info="curl http://192.168.2.119:8080/goform/Deviceinfo.xml | oq -i xml -o yaml | t2 | bl yml"
# alias denonavr="curl --insecure 'https://192.168.1.119:10443/ajax/general/get_config?type=12' | oq -i xml -o yaml '.Information' | prettier --parser yaml | bl yml"
# alias denonavr="curl --insecure 'https://192.168.1.119:10443/ajax/general/get_config?type=12' | oq -i xml -o yaml '.Information' | t2 | bat --style=grid -l yml"
# alias denon-avr="curl --insecure 'https://192.168.1.119:10443/ajax/general/get_config?type=12' | oq -i xml -o json --sort-keys --tab '.Information'"
# alias denon-avr="curl --insecure 'https://192.168.1.119:10443/ajax/general/get_config?type=12' | oq -i xml -o json '.Information' | jq --sort-keys --tab '{Audio:.Information.Audio,Video:.Information.Video,Zone:.Information.Zone}'"
# alias denon="curl --insecure 'https://192.168.50.136:10443/ajax/general/get_config?type=12' | xq -x '. | { Audio: .Information.Audio, HDMISignalInfo: .Information.Video.HDMISignalInfo }' | prettier --parser xml | bat --style=grid -l html"
function upg() {
bhr && echo "🟡 brew" && bhr
bupd
bupg
bclr
bhr && echo "🟡 npm" && bhr
npmo -g
npmupgg
# bhr && echo "🟡 gem" && bhr
# gemupgsys; gemupg; gemclr
# bhr && echo "🟡 cocoapods" && bhr
# pod repo update
bhr && echo "🟡 tldr" && bhr
tldr --update
# bhr && echo "🟡 rustup" && bhr
# rustup update
# bhr && echo "🟡 cargo" && bhr
# cgout; cgupg
bhr && echo "🟡 antidote update" && bhr
abupd
exit
}
function tapianalyze() {
tapi-analyze -v "$@" | bat --style=grid -l yml
} && compdef tapianalyze=tapi-analyze
function wifi() {
m wifi status | bat --file-name='airport --getinfo' -l yml
networksetup -getinfo 'Wi-Fi' | bat --file-name='networksetup -getinfo Wi-Fi' -l yml
}
# alias wifi-setmanual-hotspot='networksetup -setmanual Wi-Fi $(cat $DOTFILES/configs/.env.hotspot)'
# alias wifi-setmanual-r7800='networksetup -setmanual Wi-Fi $(cat $DOTFILES/configs/.env.r7800)'
# alias wifi-setmanual-e300='networksetup -setmanual Wi-Fi $(cat $DOTFILES/configs/.env.e300)'
alias mdisplay="m display status | bl yml"
alias cdt="cd ~/.TemporaryItems"
alias cdtt="cd /Volumes/T7_Shield/.TemporaryItems"
alias mvtt=" mv -t /Volumes/T7_Shield/.TemporaryItems"
alias cptt=" cp -t /Volumes/T7_Shield/.TemporaryItems"
alias cdd="cd ~/Downloads"
alias lmd="lm --color=always ~/Downloads | tail --lines=\$(ty)"
alias o="open ."
# function o() {
# test $# -eq 0 && open . || open $@
# }; compdef o=open
# alias sw_vers="echo 10.14.6"
# alias sw_vers="echo 10.14.6; &>/dev/null"
# test -x "$(which awless)" && source <(awless completion zsh)
# test -x "$(which awless)" && source "$DOTFILES/completions/awless.completion.zsh"
# alias fastboot="arch -x86_64 fastboot"
function phone-bak() {
local i && for i in "data" "DCIM" "Documents" "Download" "Pictures" "SwiftBackup"; do
adb pull "/sdcard/$i/"
done
if [[ -d "Pictures" ]]; then
fd --search-path "Pictures" --type=directory --hidden --case-sensitive --glob ".thumbnails" --exec-batch rm -rf
fi
[[ ! -d "Download" ]] && mkdir -p "Download"
adb shell pm list packages -a -3 | sed 's/^package://' | sortt >Download/pm_user.log
adb shell pm list packages -a -3 -d | sed 's/^package://' | sortt >Download/pm_user_disabled.log
adb shell pm list packages -a -s -d | sed 's/^package://' | sortt >Download/pm_system_disabled.log
}
function fbak() {
local outzip="$HOME/Downloads/$*.bak.$(dateiso).zip"
[[ -e "$outzip" ]] && rd "$outzip"
echo
fd --base-directory=$HOME --search-path=Library \
--exclude=Caches --exclude=CrashReporter --exclude=WebKit --exclude=.git \
--type=file --full-path "$*" \
--exec-batch zip -r "$outzip"
echo && l "$outzip"
}
function app-bak() {
# echo "🟡 # -> '$#'"
if [[ -z "$1" ]]; then
echo "🔴 Application name required"
return 1
fi
local appdir="$HOME/Library/Application Support/$1"
# echo "🟡 appdir -> '$appdir'"
if [[ ! -d "$appdir" ]]; then
echo "🔴 No such file or directory -> '$appdir'"
return 1
fi
local date="$(dateiso)"
# echo "🟡 date -> '$date'"
local tarname="${1//\// } ($date).tar.gz"
# echo "🟡 tarname -> '$tarname'"
local tarpath="$HOME/Downloads/$tarname"
# echo "🟡 tarpath -> '$tarpath'"
if [[ -e "$tarpath" ]]; then
rm -iv "$tarpath"
if [[ -e "$tarpath" ]]; then
echo "🔴 Aborted, existing backup exists"
return 1
fi
fi
cd "$appdir"
dstore
tar --create --gzip --verbose --preserve-permissions --file "$tarpath" --exclude='.git' '.' | lscolors
cd "$OLDPWD"
echo && echo "🟢 Backup complete"
echo && eza --oneline "$tarpath"
}
local SUBLIME_DATA="$(realpath "$HOME/Library/Application Support/Sublime Text")"
alias st="subl"
alias stn="subl --new-window"
alias sto="subl --new-window --command 'prompt_select_workspace'"
alias stcd="cd '$SUBLIME_DATA'"
alias stcdp="cd '$SUBLIME_DATA/Packages'"
alias stcdu="cd '$SUBLIME_DATA/Packages/User'"
alias stst="subl --project '$SUBLIME_DATA/Packages/User/Projects/Sublime Text.sublime-project'"
alias stgs="(stcd && gs)"
alias stgl="(stcd && gla --max-count=1)"
alias stpush="(stcd && gpush)"
function stbak() {
(
cd "$(dirname "$SUBLIME_DATA")"
local name="$(basename "$SUBLIME_DATA")"
tar --create --gzip --preserve-permissions --verbose --file "$HOME/Downloads/$name ($(dateiso)).tar.gz" "$name" | lscolors
echo && l "$HOME/Downloads/$name ($(dateiso)).tar.gz"
)
}
alias sm="smerge"
alias smo="smerge ."
declare VSCODE_DATA="$(realpath "$HOME/Library/Application Support/VSCodium")"
alias vs="code"
alias vsn="code --new-window"
alias vscd="cd '$VSCODE_DATA'"
alias vscdp="cd '$HOME/.vscode-oss/extensions'"
alias vscdu="cd '$VSCODE_DATA/User'"
unalias dotsrc &>/dev/null
alias dot="subl --project '$SUBLIME_DATA/Packages/User/Projects/Dotfiles.sublime-project'"
alias dotgs="(dotcd && gs)"
alias dotgl="(dotcd && gla --max-count=1)"
alias dotpush="(dotcd && gpush) && zcomp"
alias kk="killall -KILL \
\
QuickLookUIService \
LookupViewService \
AvatarPickerMemojiPicker \
com.apple.AmbientDisplayAgent \
com.apple.geod \
com.apple.appkit.xpc.openAndSavePanelService \
com.apple.speech.speechsynthesisd \
com.apple.iCloudHelper \
SimAudioProcessorService \
SimStreamProcessorService \
SimulatorTrampoline \
com.apple.CoreSimulator.CoreSimulatorService \
SimLaunchHostService \
SimLaunchHost.x86 \
SimLaunchHost.arm64 \
IDECacheDeleteAppExtension \
VBoxXPCOMIPCD \
VBoxSVC \
VBoxNetDHCP \
screencapture \
screencaptureui \
java \
gradle \
mono \
mono-sgen64 \
mono-sgen32 \
dotnet \
script \
ibtoold \
dart \
node \
npm \
esbuild \
tail \
deno \
redis-server \
postgres \
cargo \
rustc \
rustup \
rust-analyzer \
rls \
ld \
clang \
clangd \
go \
ruby \
srb \
sorbet \
nghttpx \
just \
watchexec \
watchman \
Jellyfin\ \
Server \
jellyfin \
EmbyServer \
embytray \
ffprobe \
ffmpeg \
nginx \
h2o \
rogcat \
adb \
Stats \
rclone \
unftp \
pueued \
sshd \
bore \
task \
tsh \
psql \
prettierd \
\
; mac-brightnessctl 1.00 \
; fd --search-path ~/.prettierd --type=file --hidden --exec-batch rm \
; bhr && pcs"
# unalias k &>/dev/null
# function k() {
# local cmds=$@
# if [[ $# -eq 0 ]]; then
# cmds=(
# "com.apple.CoreSimulator.CoreSimulatorService"
# "dart"
# "dotnet"
# "gradle"
# "ibtoold"
# "IDECacheDeleteAppExtension"
# "java"
# "just"
# "mono"
# "mono-sgen32"
# "mono-sgen64"
# "node"
# "npm"
# "rls"
# "rust-analyzer"
# "script"
# "SimAudioProcessorService"
# "SimLaunchHostService"
# "SimStreamProcessorService"
# "SimulatorTrampoline"
# "watchexec"
# )
# fi
# killall -KILL "$cmds"
# } && compdef k=killall