-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_aliases
More file actions
328 lines (257 loc) · 11.2 KB
/
Copy pathdot_aliases
File metadata and controls
328 lines (257 loc) · 11.2 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
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
# Helpers used below (defined in dot_functions):
# alias:safe sets unless command exists; warns on skip (default)
# alias:fallback sets unless command exists; silent on skip (polyfills)
# plain `alias` for deliberate shadows (cat→bat, top→btop, etc.)
# or syntax the helpers can't wrap (`alias -s`, `alias -- -=`)
# -------------------------- Filesystem & Navigation ------------------------- #
# Make the dirs command useful (deliberate shadow of zsh builtin)
alias dirs='dirs -v'
# Easier navigation: .., ..., ...., ....., ~ and -
alias:safe ..="cd .."
alias:safe ...="cd ../.."
alias:safe ....="cd ../../.."
alias:safe .....="cd ../../../.."
alias:safe ~="cd ~"
alias -- -="cd -"
# Prefer lsd if available, otherwise colorize ls (deliberate shadow of /bin/ls)
if cmd:exists lsd; then
alias ls='lsd'
else
alias ls='command ls -G'
export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
fi
# List all files colorized in long format
alias:safe l="ls -lF"
# List all files colorized in long format, excluding . and ..
alias:safe la="ls -lAF"
# List only directories (renamed from `lsd` to avoid colliding with the
# brew binary, which `ls` already aliases to)
alias:safe lsdir="command ls -lF | grep --color=never '^d'"
# Print each PATH entry on a separate line
alias:safe path='echo -e ${PATH//:/\\n}'
# ------------------------------- System Tools ------------------------------- #
# Deliberate shadows: prefer modern replacements when installed
cmd:exists python3 && alias python=python3
cmd:exists btop && alias top='btop'
cmd:exists bat && alias cat='bat --paging=never'
# Safer rm (prefer trash-put if installed)
# Directories matching TRASH_SKIP (set in .exports) bypass trash and are
# permanently deleted to avoid bloating ~/.local/share/Trash.
if cmd:exists trash-put; then
rm() {
local flags=() delete=() trash=()
for arg in "$@"; do
case "$arg" in
-*) flags+=("$arg") ;;
*)
if [[ -n "${TRASH_SKIP:-}" && "${arg##*/}" == @(${TRASH_SKIP}) ]]; then
delete+=("$arg")
else
trash+=("$arg")
fi
;;
esac
done
(( ${#delete[@]} )) && command rm "${flags[@]}" "${delete[@]}"
(( ${#trash[@]} )) && trash-put "${flags[@]}" "${trash[@]}"
}
fi
# Deliberate shadows: lazy-load SSH keys, allow interactive bash
alias ssh='ssh -o AddKeysToAgent=yes'
alias bash='PERMIT_BASH=true bash'
# Reload the shell (i.e. invoke as a login shell)
# shellcheck disable=SC2139
alias:safe reload="exec ${SHELL} -l"
# --------------------------------- AI Tools --------------------------------- #
# Deliberate shadows: wrap CLIs with permissive defaults
alias claude="claude --dangerously-skip-permissions"
alias codex="codex --yolo"
alias copilot="copilot --allow-all"
alias:safe kiro="kiro-cli"
# ------------------------------- macOS Tweaks ------------------------------- #
# Lock the screen (when going AFK), relies on "Require password after sleep"
alias:safe afk='pmset displaysleepnow'
# Show/hide hidden files in Finder
alias:safe show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias:safe hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
# Hide/show all desktop icons (useful when presenting)
alias:safe hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias:safe showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# Flush Directory Service cache
alias:safe flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
# Clean up LaunchServices to remove duplicates in the "Open With" menu
alias:safe lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
# Disable / enable Spotlight
alias:safe spotoff="sudo mdutil -a -i off"
alias:safe spoton="sudo mdutil -a -i on"
# Empty the Trash on all mounted volumes, macOS Trash, freedesktop Trash + logs/quarantine
alias:safe emptytrash="sudo /bin/rm -rfv /Volumes/*/.Trashes; sudo /bin/rm -rfv ~/.Trash; /bin/rm -rfv ~/.local/share/Trash/files/* ~/.local/share/Trash/info/*; sudo /bin/rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
# Recursively delete `.DS_Store` files
alias:safe cleanup="find . -type f -name '*.DS_Store' -ls -delete"
# Volume controls
alias:safe stfu="osascript -e 'set volume output muted true'"
alias:safe pumpitup="osascript -e 'set volume output volume 100'"
# -------------------------------- Networking -------------------------------- #
# Local IP addresses
alias:safe ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias:safe localip="ipconfig getifaddr en0"
alias:safe ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# Public IP via ifconfig.me
alias:safe myip='curl -s ifconfig.me'
# Show active network interfaces
alias:safe ifactive="ifconfig | awk '/^[^ ]/{iface=\$1} /status: active/{print iface}'"
# Show listening ports
alias:safe ports='lsof -i -P -n | grep LISTEN'
# ------------------------------- Kubernetes --------------------------------- #
cmd:exists kubectl && alias:safe k='kubectl'
cmd:exists kubens && alias:safe kn='kubens'
cmd:exists kubectx && alias:safe kx='kubectx'
# --------------------------------- Utilities -------------------------------- #
# Always enable colored `grep` output (deliberate self-shadow of /usr/bin/grep)
alias grep='grep --color=auto'
# Enable aliases to be sudo'ed (deliberate shadow with trailing-space trick)
alias sudo='sudo '
# Update macOS, Homebrew, npm globals, and Ruby gems (guards each tool)
alias:safe update='sudo softwareupdate -i -a; brew update && brew upgrade && brew cleanup; cmd:exists npm && npm update -g; cmd:exists gem && sudo gem update --system && sudo gem update && sudo gem cleanup'
# macOS doesn't ship `hd` / `md5sum` / `sha1sum`. alias:fallback sets them
# silently on systems where the real binary is missing.
alias:fallback hd="hexdump -C"
alias:fallback md5sum="md5"
alias:fallback sha1sum="shasum"
# JavaScriptCore REPL
if [[ -e "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc" ]]; then
alias:safe jsc="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc"
fi
# Disk usage of current dir entries (sorted) and free space
alias:safe dud='du -sh * | sort -h'
alias:safe duf='df -h'
# Make a file executable
alias:safe chx='chmod +x'
# Trim new lines and copy to clipboard
alias:safe c="tr -d '\n' | pbcopy"
# URL-encode strings
alias:safe urlencode='python3 -c "import sys, urllib.parse; print(urllib.parse.quote_plus(sys.argv[1]))"'
# PlistBuddy
alias:safe plistbuddy="/usr/libexec/PlistBuddy"
# Intuitive map function
# For example, to list all directories that contain a certain file:
# find . -name .gitattributes | map dirname
alias:safe map="xargs -n1"
# Quick HTTP server in current dir
alias:safe serve='python3 -m http.server'
# Terminal weather and cheat sheets (e.g. `cheat tar`)
alias:safe weather='curl wttr.in'
alias:safe cheat='curl cheat.sh/'
# QR code in terminal (usage: echo "url" | qr)
cmd:exists qrencode && alias:safe qr='qrencode -t ANSIUTF8'
# Generate a strong random password and a lowercase UUID
alias:safe genpw='openssl rand -base64 16'
alias:safe uuid='uuidgen | tr A-Z a-z'
# Top 20 most-used commands from history
alias:safe myhist='history | awk "{print \$2}" | sort | uniq -c | sort -rn | head -20'
# --------------------------- Time / Productivity ---------------------------- #
# Stopwatch (press enter to stop)
alias:safe timer='time read -p "Press enter to stop"'
# Get week number
alias:safe week='date +%V'
# Current date+time, today's date, Unix epoch seconds
alias:safe now='date +"%Y-%m-%d %H:%M:%S"'
alias:safe today='date +"%Y-%m-%d"'
alias:safe epoch='date +%s'
# ------------------------------ JSON / Data --------------------------------- #
cmd:exists jq && alias:safe jqp='jq .'
alias:safe json='python3 -m json.tool'
# ------------------------------ Docker -------------------------------------- #
cmd:exists docker && {
alias:safe d='docker'
alias dc='docker compose' # deliberate shadow of /usr/bin/dc (RPN calculator)
alias:safe dps='docker ps'
alias:safe dpsa='docker ps -a'
alias:safe dimg='docker images'
alias:safe dprune='docker system prune -af'
}
# -------------------------------- Fun & Dumb -------------------------------- #
# Polite / British
alias:safe please='sudo '
alias:safe pretty-please='sudo !!'
alias:safe cheers='exit'
alias:safe ta='exit'
alias:safe gtfo='exit'
alias:safe fucking='sudo '
# Sci-Fi
alias:safe engage='git push'
alias:safe make-it-so='git commit -am'
alias:safe boom='git push --force'
# Onomatopoeia / action verbs
alias:safe nuke='rm -rf'
alias:safe yeet='git push'
alias:safe summon='brew install'
alias:safe banish='brew uninstall'
alias:safe fix-everything='brew update && brew upgrade && brew cleanup'
alias:safe omw='git push origin'
alias:safe yolo='git push --force'
alias:safe yolos='git push --force && say That was sneaky!'
# Self-deprecating
alias:safe oops='git reset --soft HEAD~1'
alias:safe damnit='git reset --hard HEAD'
alias:safe ughhh='git stash'
alias:safe wtf='git status'
alias:safe panic='git stash && git checkout main && git pull'
# Encouraging
alias:safe birth='touch'
alias:safe kill-it='pkill -f'
# ------------------------------ Editor & Config ----------------------------- #
# Prefer neovim where available (deliberate shadows of vi/vim/nvim)
if [[ ! -L "$(which "${EDITOR}")" ]]; then
if cmd:exists nvim.appimage; then
alias vi=nvim.appimage
alias vim=nvim.appimage
alias nvim=nvim.appimage
elif cmd:exists nvim; then
alias vi=nvim
alias vim=nvim
elif cmd:exists vim; then
alias vi=vim
alias vim=vim
fi
fi
# Edit shell config / variables (chezmoi source files)
alias:safe es='chezmoi edit ~/.zshrc'
alias:safe ev='chezmoi edit ~/.exports'
# Open editor in current directory
alias:safe e='$EDITOR .'
# ------------------------------------ Git ----------------------------------- #
alias:safe g="git"
alias:safe gs="git status"
alias:safe gca="git commit -a -m"
alias:safe gau="git remote add upstream"
alias:safe gaa="git add --all"
alias:safe gpl="git pull"
alias:safe gpu="git push"
alias:safe gps="git push && say You are awesome!"
alias:safe gcl="git clone"
alias:safe glg="git log"
alias:safe gst="git shortlog -sn"
alias:safe gch="git checkout"
alias:safe gba="git branch -av"
alias:safe gsl="git stash list"
alias:safe gsc="git stash clear"
alias:safe gd='git diff'
alias:safe gds='git diff --staged'
alias:safe gco='git checkout'
alias:safe gcb='git checkout -b'
alias:safe gb='git branch'
alias:safe gbd='git branch -d'
alias:safe gun='git reset HEAD~1'
alias:safe glo='git log --oneline --graph --decorate'
alias:safe gwip='git add -A && git commit -m "wip"'
alias:safe gclean='git clean -fd'
# ------------------------------- Suffix alias ------------------------------- #
# `alias -s` uses different syntax that alias:safe cannot wrap.
alias -s go='$EDITOR'
alias -s md='$EDITOR'
alias -s yaml='$EDITOR'
alias -s yml='$EDITOR'
alias -s js='$EDITOR'
alias -s ts='$EDITOR'
alias -s json='$EDITOR'