-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.aliases
510 lines (402 loc) · 15.2 KB
/
.aliases
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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
#!/usr/bin/env bash
# Easier navigation: .., ..., ...., ....., ~ and -.
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
##
# SHORTCUTS.
##
alias d="cd ~/Documents"
alias dl="cd ~/Downloads"
alias dr="cd ~/Dropbox"
alias dt="cd ~/Desktop"
alias p="cd ~/Projects"
alias s="cd ~/Sites"
alias data="cd ~/data"
alias dev="cd ~/dev"
alias dot="cd ~/dotfiles"
alias ss="cd ~/.ssh"
alias g="git"
# - - - - - - - - - - - - - - - - - - - -
# Directory Listing
# - - - - - - - - - - - - - - - - - - - -
# Always Use Colour Output For "ls".
if [[ "$OSTYPE" =~ ^darwin ]]; then
alias ls='command ls --color=auto';
COLORFLAG="--color";
export COLORFLAG;
#export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx';
export LSCOLORS='gxfxcxdxbxGxDxabagacad';
else
alias ls='command ls --color=auto';
COLORFLAG="--color"
export COLORFLAG
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:';
fi;
# List All Files Colorized In Long Format.
#alias l="ls -lF ${COLORFLAG}"
# List All Files Colorized In Long Format, Excluding . And ..
#alias la="ls -lAF ${COLORFLAG}"
# List Only Directories.
#alias lsd="ls -lF ${COLORFLAG} | grep --color=never '^d'"
# Always Use Color Output For `ls`.
alias ls='command ls "${COLORFLAG}"'
# - - - - - - - - - - - - - - - - - - - -
# ColorLS
# - - - - - - - - - - - - - - - - - - - -
alias l='colorls --gs --sd'
alias la='colorls -1A --sd --gs --report '
alias ll='colorls -lA --sd --gs --report '
alias lsd='colorls -1d --sd --gs --report '
alias lsf='colorls -1f --sd --gs --report '
alias lsg='colorls -A --sd --gs --report '
alias lst='colorls -A --sd --tree '
# - - - - - - - - - - - - - - - - - - - -
# Grep
# - - - - - - - - - - - - - - - - - - - -
# Always Enable Colored `grep` Output.
# Note: `grep_options="--color=auto"` Is Deprecated, Hence The Alias Usage.
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
##
# ENABLE ALIASES TO BE SUDO’ED.
##
alias sudo='sudo '
##
# GET WEEK NUMBER.
##
alias week='date +%V'
##
# GET macOS SOFTWARE UPDATES, AND UPDATE INSTALLED RUBY GEMS, HOMEBREW, NPM, AND THEIR INSTALLED PACKAGES.
##
#alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm install npm -g; npm update -g; sudo gem update --system; sudo gem update; sudo gem cleanup'
alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm install npm -g; sudo gem update --system; sudo gem update; sudo gem cleanup'
##
# GOOGLE CHROME.
##
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
alias canary='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
##
# IP ADDRESSES.
##
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
##
# SHOW ACTIVE NETWORK INTERFACES.
##
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
##
# FLUSH DIRECTORY SERVICE CACHE.
##
alias flush="sudo killall -HUP mDNSResponder"
##
# CLEAN UP LAUNCHSERVICES TO REMOVE DUPLICATES IN THE “OPEN WITH” MENU.
##
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
##
# VIEW HTTP TRAFFIC.
##
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
##
# CANONICAL HEX DUMP; SOME SYSTEMS HAVE THIS SYMLINKED.
##
command -v hd > /dev/null || alias hd="hexdump -C"
##
# macOS HAS NO `MD5SUM`, SO USE `MD5` AS A FALLBACK.
##
command -v md5sum > /dev/null || alias md5sum="md5"
##
# macOS HAS NO `SHA1SUM`, SO USE `SHASUM` AS A FALLBACK.
##
command -v sha1sum > /dev/null || alias sha1sum="shasum"
##
# JAVASCRIPTCORE REPL.
##
jscbin="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc";
[ -e "${jscbin}" ] && alias jsc='${jscbin}';
unset jscbin;
##
# TRIM NEW LINES AND COPY TO CLIPBOARD.
##
alias c="tr -d '\n' | pbcopy"
##
# RECURSIVELY DELETE `.DS_STORE` FILES.
##
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
##
# EMPTY THE TRASH ON ALL MOUNTED VOLUMES AND THE MAIN HDD.
# Also, clear Apple’s System Logs to improve shell startup speed.
# Finally, clear download history from quarantine. https://mths.be/bum.
##
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
##
# SHOW/HIDE HIDDEN FILES IN FINDER.
##
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
##
# HIDE/SHOW ALL DESKTOP ICONS (USEFUL WHEN PRESENTING).
##
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
##
# URL-ENCODE STRINGS.
##
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
##
# MERGE PDF FILES, PRESERVING HYPERLINKS.
# @USAGE:
# `mergepdf input{1,2,3}.pdf`
##
alias mergepdf='gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf'
##
# DISABLE SPOTLIGHT.
##
alias spotoff="sudo mdutil -a -i off"
##
# ENABLE SPOTLIGHT.
##
alias spoton="sudo mdutil -a -i on"
##
# PLISTBUDDY ALIAS, BECAUSE SOMETIMES `DEFAULTS` JUST DOESN’T CUT IT.
##
alias plistbuddy="/usr/libexec/PlistBuddy"
##
# RING THE TERMINAL BELL, AND PUT A BADGE ON TERMINAL.APP’S DOCK ICON.
# (useful when executing time-consuming commands)
##
alias badge="tput bel"
##
# INTUITIVE MAP FUNCTION.
# @EXAMPLE: To list all directories that contain a certain file:
# find . -name .gitattributes | map dirname
##
alias map="xargs -n1"
##
# ONE OF @JANMOESEN’S PROTIP™S.
##
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
alias "${method}"='lwp-request -m "$method"'
done
##
# MAKE GRUNT PRINT STACK TRACES BY DEFAULT.
##
command -v grunt > /dev/null && alias grunt="grunt --stack"
##
# STUFF I NEVER REALLY USE BUT CANNOT DELETE EITHER BECAUSE OF HTTP://XKCD.COM/530/.
##
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume output volume 100'"
##
# KILL ALL THE TABS IN CHROME TO FREE UP MEMORY.
###
alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
##
# LOCK THE SCREEN (WHEN GOING AFK).
##
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
##
# RELOAD THE SHELL (I.E. INVOKE AS A LOGIN SHELL).
##
alias reload='exec ${SHELL} -l'
##
# PRINT EACH PATH ENTRY ON A SEPARATE LINE.
##
alias path='echo -e ${PATH//:/\\n}'
##
# ADD A "SPACER" TO THE macOS DOCK.
##
alias adddockspacer="defaults write com.apple.dock persistent-apps -array-add '{\"tile-type\"=\"spacer-tile\";}' && killall Dock";
#
# ----------------------------------------------------------------------------------------------------------------------
#
# APPLICATION-SPECIFIC ALIASES
#
# ----------------------------------------------------------------------------------------------------------------------
#
################################################################################
#
# NPM
#
################################################################################
# `npm` ALIAS.
alias np='npm';
# `npm install` ALIAS.
alias npi='npm i';
alias npis='npm i --save';
alias npig='npm i -g';
# `npm list` ALIAS.
alias npl='npm ls --depth=0';
alias nplg='npm ls -g --depth=0';
# `npm search`
alias nps='npm search';
# `npm test` ALIAS.
alias npt='npm t';
# `npm update` ALIAS.
alias npu='npm up';
alias npug='npm up -g';
# `npm uninstall` ALIAS.
alias npun='npm un';
alias npung='npm un -g';
################################################################################
#
# YARN
#
################################################################################
# `yarn` ALIAS.
alias yar='yarn';
# `yarn add` ALIAS.
alias yarna='yarn add';
alias yarnad='yarn add -D';
alias yarnap='yarn add -P';
alias yarnag='yarn global add';
# `yarn install` ALIAS.
alias yarni='yarn install';
# `yarn list` ALIAS.
alias yarnl='yarn list --depth=0';
alias yarnlg='yarn global list --depth=0';
# `yarn remove` ALIAS.
alias yarnr='yarn remove';
alias yarnrg='yarn global remove';
# `yarn search` ALIAS.
alias yarns='yarn search';
# `yarn test` ALIAS.
alias yarnt='yarn test';
# `yarn upgrade` ALIAS.
alias yarnu='yarn upgrade';
alias yarnui='yarn upgrade-interactive';
alias yarnuig='yarn global upgrade-interactive';
################################################################################
#
# APACHE
#
################################################################################
# alias startapache="sudo brew services start httpd"
# alias stopapache="sudo brew services stop httpd"
# alias restartapache="sudo brew services restart -k httpd"
alias startapache="sudo apachectl start"
alias stopapache="sudo apachectl -k stop"
alias restartapache="sudo apachectl -k restart"
################################################################################
#
# assh — ( Formerly, Advanced SSH Config )
#
################################################################################
alias assh="assh wrapper ssh"
################################################################################
#
# Brew Graph
#
################################################################################
alias brew-deps="brew deps --installed"
#alias brew-graph="brew graph --installed | dot -Tpng -ograph.png && open graph.png"
alias brew-graph="brew graph --installed --highlight-leaves | fdp -Tpng -ograph.png && open graph.png"
################################################################################
#
# Bundler
#
################################################################################
alias bi="bundle install"
alias be="bundle exec "
alias bu="bundle update"
alias bo="bundle open"
################################################################################
#
# DNSMASQ
#
################################################################################
alias startdnsmasq="sudo brew services start dnsmasq"
alias stopdnsmasq="sudo brew services stop dnsmasq"
alias restartdnsmasq="sudo brew services restart dnsmasq"
################################################################################
#
# DOCKER
#
################################################################################
alias dklc='docker ps -l' # LIST LAST DOCKER CONTAINER
alias dklcid='docker ps -l -q' # LIST LAST DOCKER CONTAINER ID
alias dklcip='docker inspect -f "{{.NetworkSettings.IPAddress}}" $(docker ps -l -q)' # GET IP OF LAST DOCKER CONTAINER
alias dkps='docker ps' # LIST RUNNING DOCKER CONTAINERS
alias dkpsa='docker ps -a' # LIST ALL DOCKER CONTAINERS
alias dki='docker images' # LIST DOCKER IMAGES
alias dkrmac='docker rm $(docker ps -a -q)' # DELETE ALL DOCKER CONTAINERS
alias dkrmlc='docker-remove-most-recent-container' # DELETE MOST RECENT (I.E., LAST) DOCKER CONTAINER
alias dkelc='docker exec -it `dklcid` bash' # ENTER LAST CONTAINER (WORKS WITH DOCKER 1.3 AND ABOVE)
# OS-SPECIFIC IMAGE CLEANUP.
case $OSTYPE in
darwin*|*bsd*|*BSD*)
alias dkrmui='docker images -q -f dangling=true | xargs docker rmi' # DELETE ALL UNTAGGED DOCKER IMAGES
;;
*)
alias dkrmui='docker images -q -f dangling=true | xargs -r docker rmi' # DELETE ALL UNTAGGED DOCKER IMAGES
;;
esac
# CLEANUP.
alias docker-clean-all='docker container stop $(docker container ls -a -q) && docker system prune -a -f --volumes'
alias docker-clean-containers='docker container stop $(docker container ls -a -q) && docker container rm $(docker container ls -a -q)'
alias docker-clean-unused='docker system prune --all --force --volumes'
################################################################################
#
# GIT
#
################################################################################
alias gitdelete='git branch | egrep -v "(main|master|staging|develop|release|release_candidate\*)" | xargs git branch -D'
################################################################################
#
# MONGO DATABASE
#
################################################################################
alias startmongo="mongod --dbpath ~/data/db --fork --logpath /dev/null"
alias stopmongo="mongo admin --eval 'db.shutdownServer()' > /dev/null"
################################################################################
#
# MYSQL DATABASE
#
################################################################################
##
# MariaDB
##
#alias startmysql="brew services start mariadb"
#alias stopmysql="brew services stop mariadb"
##
# MySQL
##
#alias startmysql="brew services start mysql"
#alias stopmysql="brew services stop mysql"
#alias restartmysql="brew services restart mysql"
##
# MySQL ( v5.7 )
##
alias startmysql="brew services start mysql@5.7"
alias stopmysql="brew services stop mysql@5.7"
alias restartmysql="brew services restart mysql@5.7"
################################################################################
#
# POSTGRESQL DATABASE
#
################################################################################
alias startpostgres="brew services start postgresql"
alias stoppostgres="brew services stop postgresql"
################################################################################
#
# MANAGING MULTIPLE AWS EKS CLUSTERS
#
################################################################################
alias eks-main-prod='export AWS_PROFILE=canvasprod && aws eks update-kubeconfig --name prod-eks && source <(kubectl completion bash)'
alias eks-main-int='export AWS_PROFILE=canvasprod && aws eks update-kubeconfig --name int-eks && source <(kubectl completion bash)'
alias eks-canvastest-int='export AWS_PROFILE=canvastest && aws eks update-kubeconfig --name int-eks && source <(kubectl completion bash)'
alias eks-canvastest-int-gc-dev='export AWS_PROFILE=canvastest && aws eks update-kubeconfig --name int-eks && source <(kubectl completion bash) && kubectl config set-context $(kubectl config current-context) --namespace gc-dev'
alias disco-aws='export AWS_PROFILE=gc-dev-disco';
# - - - - - - - - - - - - - - - - - - - -
# Code Editor + IDE
# - - - - - - - - - - - - - - - - - - - -
# Open .zshrc To Be Edited In Vs Code
alias change='code-insiders ~/.bashrc'
# Re-Run Source Command On .zshrc To Update Current Terminal Session With New Settings
alias update='source ~/.bashrc'