forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.aliases
525 lines (452 loc) · 17.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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# 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/Dropbox"
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
# alias p="cd ~/projects"
alias g="git"
alias h="history"
alias j="jobs"
# alias v="vim"
alias s="subl ."
alias o="open"
alias oo="open ."
alias pgrep="pgrep -fl "
alias rgi='rg -i'
alias fcz='fzc' # fuzzy code open
alias reset="clear && printf '\e[3J'" # clear terminal properly
alias awk1="awk '{print \$1}'"
alias awk2="awk '{print \$2}'"
alias awk3="awk '{print \$3}'"
alias awk4="awk '{print \$4}'"
alias awk5="awk '{print \$5}'"
alias awk6="awk '{print \$6}'"
alias awk7="awk '{print \$7}'"
alias awk8="awk '{print \$8}'"
alias awk9="awk '{print \$9}'"
alias awk10="awk '{print \$10}'"
alias awk11="awk '{print \$11}'"
alias awk12="awk '{print \$12}'"
alias awk13="awk '{print \$13}'"
alias awk14="awk '{print \$14}'"
alias awk15="awk '{print \$15}'"
# # Detect which `ls` flavor is in use
# if ls --color > /dev/null 2>&1; then # GNU `ls`
# colorflag="--color"
# else # OS X `ls`
# colorflag="-G"
# fi
colorflag="-G"
# List all files colorized in long format
alias ll="ls -lhF ${colorflag}"
# List all files colorized in long format, including dot files
alias l="ls -lahF ${colorflag}"
# List only directories
alias lsd='ls -l ${colorflag} | grep "^d"'
# Always use color output for `ls`
alias ls="command ls -h ${colorflag}"
# alias ls="lsd" # brew info lsd
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:'
# 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 OS X 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'
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en1"
alias ips="ifconfig -a | grep -o 'inet6\? \(\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\|[a-fA-F0-9:]\+\)' | sed -e 's/inet6* //'"
# Flush Directory Service cache
alias flush="dscacheutil -flushcache && 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 'en0' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en0 -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"
# OS X has no `md5sum`, so use `md5` as a fallback
command -v md5sum > /dev/null || alias md5sum="md5"
# OS X 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"
alias trim="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
# Usage: `mergepdf -o output.pdf input{1,2,3}.pdf`
alias mergepdf='/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py'
# 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
# For example, to list all directories that contain a certain file:
# find . -name .gitattributes | map dirname
alias map="xargs -n1"
alias mapi="xargs -n1 -I{}"
# 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 7'"
# 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"
################################################################################################################
################################################################################################################
################################################################################################################
################################################################################################################
# Alias vi => vim
alias vi='vim'
# Bash Aliases
alias k9='kill -9'
alias wh='which'
# alias c='clear'
# alias k='clear'
alias rmrf='trash'
alias rmforce='rm -rf'
alias tczf='tar czf'
alias s='subl'
alias s.='subl .'
alias t='tree'
alias se='code ~/dotfiles/.extras'
alias se='code ~/dotfiles/.extras'
alias sal='code ~/dotfiles/.aliases'
# Shellcheck ignore
alias sd="code $(realpath ~/dotfiles)"
alias sf='code ~/dotfiles/.functions'
alias sz='code ~/.zshrc'
alias szh='code ~/.zsh_history'
# alias srz='source ~/.zshrc' # Breaks for some reason :/
alias srz='reload'
alias st3='cd ~/Library/Application\ Support/Sublime\ Text\ 3/'
alias sbp='subl ~/.bash_profile'
alias sj='subl "~/personal/Google Drive/journal.md"'
alias ssh_='sshrc'
# Prevent mosh from entering alternate screen mode (which is annoying, and disables mouse support)
alias mosh='mosh --no-init '
# Short Git aliases
alias gi='git init'
alias gir='git init; touch readme.md;gaa;'
alias gii='git init; touch .gitignore;gaa;'
alias giir='git init; touch .gitignore readme.md; echo "node_modules/\ncoverage/" >> .gitignore;gaa;'
alias inm='echo "node_modules/" >> .gitignore'
alias gs='git status'
alias gsd='git status'
alias gss='git status -s -b'
alias gsgd='git status; git diff'
alias ghis='git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'
alias gst='git stash'
alias gstl='git stash list'
alias gsta='git stash apply'
alias gstp='git stash save --patch'
alias ga='git add'
alias gap='git add -p'
alias ggap='git add -p'
alias gau='git add -u'
alias gaa='git add .;gs'
alias gre='git reset'
alias greh='git reset --h'
alias gmff='git merge --ff'
alias gmv='git mv'
alias grm='git rm'
alias grmf='git rm -f'
alias grmrf='git rm -rf'
alias grmdel='git rm $(git ls-files --deleted)'
alias gb='git branch'
alias gbm='git branch --move'
alias gbc='git rev-parse --abbrev-ref HEAD'
alias currentbranch='git rev-parse --abbrev-ref HEAD'
alias gcfg='git config'
alias gcl=clonecd
alias gclr='git clone --recursive'
alias gc='git commit'
alias gcf='git commit --fixup'
alias gcv='git commit -v'
alias gcvn='git commit -v --no-verify'
alias gc!='git commit --amend'
alias gcn='git commit --amend --no-edit'
alias gcv!='git commit --amend -v'
alias gcm='git commit -v -m'
alias gcam='git commit -a -m'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcop='git checkout -p'
alias gclean='git clean '
alias gd='git diff'
alias gdc='git diff --cached'
alias gdh='git diff head'
alias gf='git fetch'
alias gl='git log --format="%C(auto)%h%Creset %Cgreen[%an]%Creset %C(auto)(%ah)%Creset %C(auto)%d%Creset %s"'
alias gt='git log --graph --abbrev-commit --decorate --oneline'
alias gll='git log'
alias gpl='git pull'
alias gplr='git pull --rebase'
alias gplri='git pull --rebase=i'
alias gplro='git pull --rebase origin'
alias gplroi='git pull --rebase=i origin'
alias gplru='git pull --rebase upst'
alias gplrui='git pull --rebase=i upst'
alias gplrob='git pull --rebase origin `git branch --show-current`'
alias gplrobi='git pull --rebase=i origin `git branch --show-current`'
alias gplron='git pull --rebase origin next'
alias gplroni='git pull --rebase=i origin next'
alias gplrogh='git pull --rebase origin gh-pages'
alias gplroghi='git pull --rebase=i origin gh-pages'
alias gplrod='git pull --rebase origin develop; gsu'
alias gplrodi='git pull --rebase=i origin develop; gsu'
alias gplrugh='git pull --rebase upst gh-pages'
alias gplrughi='git pull --rebase=i upst gh-pages'
alias gplrud='git pull --rebase upst develop'
alias gplrudi='git pull --rebase=i upst develop'
alias gplo='git pull origin'
alias gplod='git pull origin develop'
alias gplu='git pull upst'
alias gplud='git pull upst develop'
alias gp='git push'
alias gpf='git push --force-with-lease'
alias gpfn='git push --force-with-lease --no-verify'
alias gpo='git push origin'
alias gpodel='git push origin --delete'
alias gpu='git push upst'
alias gpod='git push origin develop'
alias gpogh='git push origin gh-pages'
alias gpud='git push upst develop'
alias gpugh='git push upst gh-pages'
alias grb='git rebase'
alias grbc='git rebase --continue'
alias gr='git remote'
alias gra='git remote add'
alias grao='git remote add origin'
alias grau='git remote add upst'
alias grr='git remote rm'
alias grro='git remote rm origin'
alias grru='git remote rm upst'
alias grv='git remote -v'
alias gsu='git submodule update --init --recursive'
alias gsuc='git submodule update --init --recursive --checkout'
alias gsur='git submodule update --init --recursive --rebase'
alias gba='git branch -a'
alias del='git branch -d'
alias delD='git branch -D'
alias gco-='git checkout -'
alias gfo='git fetch origin'
alias gcp='git cherry-pick'
alias grb="git rebase"
alias grbi="git rebase --interactive"
alias grba="git rebase --abort"
alias undo_head="git reset HEAD~"
# Work aliases
alias glint='grunt parallelize:coffeelint:app'
alias tb='coffee ./run-tests.coffee "*" -l smoke --to 80000'
alias lf='lastfails'
alias lfa='lastfailsacc'
alias lfw='lastfailswat'
alias mm='coffee ./run-tests.coffee'
alias mw='coffee ./run-tests.coffee -a wwwstage'
alias az1='ssh [email protected]'
alias az2='ssh [email protected]'
alias tanq='ssh [email protected]'
# use az2
# su - docusign
# ssh ec2-jenkins01
# Common cd for convenience
alias cc='cd ~/personal/Dropbox/devWork/code'
alias cce='cd ~/personal/Dropbox/devWork/code/elm'
alias cn='cd ~/personal/Dropbox/devWork/nonCodeProjects'
alias cw='cd ~/work'
alias cwa='cd ~/work/app'
alias cwad='cd ~/work/devApp'
alias cwar='cd ~/work/code_work/aperture-rift'
alias cwarf='cd ~/work/code_work/aperture-rift/dev-portal'
alias cwd='cd ~/work/debugApp'
alias cwas='cd ~/work/code_work/edited_account_creation_scripts'
alias cwc='cd ~/work/code_work'
alias cwf='cd ~/work/code_work/flo'
alias cwj='cd ~/work/code_work/jeeves'
alias cwo='cd ~/work/code_work/olive'
alias cwn='cd ~/work/npmE-ds'
alias cwr='cd ~/work/code_work/radmin'
alias cco='cd ~/personal/Dropbox/devWork/open_source'
alias ccm='cd ~/personal/Dropbox/devWork/code/node/modules'
alias ccp='cd ~/personal'
alias cws='cd ~/work/code_work/statsBoard'
alias cwt='cd ~/work/testApp'
alias cwb='cd ~/work/debugApp'
alias cww='cd ~/work/code_work/wookie'
alias csub='cd ~/Library/Application\ Support/Sublime\ Text\ 3/'
alias d='cd ~/personal/Dropbox'
# alias p='cd ~/personal/Dropbox/devWork/code/node/projects'
alias lew="cd ~/personal/Dropbox/devWork/code/node/projects/htmlLemmings/projects/lemmings"
alias nn="cd ~/personal/neural-news"
# bin Shortcuts
alias nw='/Applications/node-webkit.app/Contents/MacOS/node-webkit'
alias py3='python3 '
alias yt='yt-dlp '
alias ytv='yt-dlp -f 22 '
alias yt3='yt-dlp -x --audio-format mp3 '
# npm aliases
alias ni='npm i'
alias nig='npm i -g'
alias nupdate='npm i -g npm'
alias nt='npm test'
alias nr='npm run'
alias nig='npm install -g'
alias nis='npm install --save'
alias nisd='npm install --save-dev'
alias nus="npm uninstall $@ --save"
alias nusd="npm uninstall $@ --save-dev"
alias nise='npm i --save --save-exact'
alias nisde='npm i --save-dev --save-exact'
# yarn aliases
alias y='yarn'
alias yy='yarn why'
alias yl='yarn list --pattern'
alias ya='yarn add'
alias yad='yarn add --dev'
alias yap='yarn add --peer'
alias yae='yarn add --exact'
alias yag='yarn global add'
alias yade='yarn add --dev --exact'
alias yr="yarn run"
alias yrm="yarn remove $@"
alias yrd="yarn remove $@ --dev"
alias yfoo="yarn add is-regexp && yarn remove is-regexp"
# arcanist aliases
alias ad='arc diff'
alias al='arc land'
alias adv='arc diff --verbatim'
alias adr='arc diff -m rebase'
alias adm='arc diff -m '
alias adp='arc diff --plan-changes'
alias adpv='arc diff --plan-changes --verbatim'
# re-map apache benchmark tool to abb
alias abb="ab"
alias ab="arc branch"
# arc funcs
function ads() {
arc diff `gupstream`
}
function advs() {
arc diff --verbatim `gupstream`
}
function adrs() {
arc diff -m 'rebase' `gupstream`
}
function adms() {
arc diff `gupstream` -m "'$1'"
}
function adps() {
arc diff --plan-changes `gupstream`
}
function adpvs() {
arc diff --plan-changes --verbatim `gupstream`
}
########### appended aliases
alias met='meteor'
alias metls='meteor list'
alias metlu='meteor list --using'
alias ут='en'
alias кг='ru'
# alias npm='npm substack'
alias chr='open -a /Applications/Google\ Chrome\ Canary.app'
alias ebook-convert='/Applications/calibre.app/Contents/console.app/Contents/MacOS/ebook-convert'
alias lt='echo "please install exa or tree"'
if [[ $(command -v exa) ]]; then
alias l='exa -lahF'
alias ll='exa -lhF'
alias lt='exa -lahF -T'
else
if [[ $(command -v tree) ]]; then
alias lt='tree'
fi
fi
if [[ $(command -v fd) ]]; then
alias fdp='fd -p'
fi
if [[ $(command -v rg) ]]; then
alias rg='rg -i'
# rg raw
alias rgr='rg'
# rg case-sensitive
alias rgI='rg'
fi
alias git_default_branch="git rev-parse --abbrev-ref origin/HEAD 2>/dev/null | sed 's/origin\///'"
function gplrom() {
git pull --rebase origin "$(git_default_branch)"
}
function gplromi() {
git pull --rebase=interactive origin "$(git_default_branch)"
}
function gplom() {
git pull origin "$(git_default_branch)"
}
function gcom() {
git checkout "$(git_default_branch)"
}
function gplrum() {
git pull --rebase upst "$(git_default_branch)"
}
function gplum() {
git pull upst "$(git_default_branch)"
}
function gpfom() {
local def_branch
def_branch="$(git_default_branch)"
read -p "Are you sure you want to force push to origin/$def_branch? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git push --force-with-lease origin "$def_branch"
fi
}
function gpom() {
git push origin "$(git_default_branch)"
}
function gpum() {
git push upst "$(git_default_branch)"
}
# allow colors in watch
alias watch='watch -c'
alias json2yaml="python -c 'import sys, yaml, json; yaml.dump(json.load(sys.stdin), sys.stdout)'"
alias yaml2json="python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin, Loader=yaml.Loader), sys.stdout, indent=4)'"