1+ #! /usr/bin/env bash
2+
13# Easier navigation: .., ..., ...., ....., ~ and -
24alias ..=" cd .."
35alias ...=" cd ../.."
@@ -12,21 +14,21 @@ alias dl="cd ~/Downloads"
1214alias dt=" cd ~/Desktop"
1315alias dw=" cd ~/Workspace"
1416alias g=" git"
15- alias h="history"
16- alias j="jobs"
1717
1818# Detect which `ls` flavor is in use
1919if ls --color > /dev/null 2>&1 ; then # GNU `ls`
2020 colorflag=" --color"
21- else # OS X `ls`
21+ export LS_COLORS=' no=00:fi=00:di=01;31: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:'
22+ else # macOS `ls`
2223 colorflag=" -G"
24+ export LSCOLORS=' BxBxhxDxfxhxhxhxhxcxcx'
2325fi
2426
2527# List all files colorized in long format
2628alias l=" ls -lF ${colorflag} "
2729
28- # List all files colorized in long format, including dot files
29- alias la="ls -laF ${colorflag}"
30+ # List all files colorized in long format, excluding . and ..
31+ alias la=" ls -lAF ${colorflag} "
3032
3133# List all files colorized in long format, including dot files, grouped and sorted
3234alias ll=" ls -larthF ${colorflag} "
@@ -36,67 +38,64 @@ alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
3638
3739# Always use color output for `ls`
3840alias ls=" command ls ${colorflag} "
39- 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:'
41+
42+ # Always enable colored `grep` output
43+ # Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
44+ alias grep=' grep --color=auto'
45+ alias fgrep=' fgrep --color=auto'
46+ alias egrep=' egrep --color=auto'
4047
4148# Enable aliases to be sudo’ed
4249alias sudo=' sudo '
4350
44- # Gzip-enabled `curl`
45- alias gurl='curl --compressed'
46-
4751# Get week number
4852alias week=' date +%V'
4953
50- # Stopwatch
51- alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date '
54+ # Get macOS Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
55+ 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 '
5256
53- # Get OS X Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
54- alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm update npm -g; npm update -g; sudo gem update --system; sudo gem update'
57+ # Google Chrome
58+ alias chrome=' /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
59+ alias canary=' /Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
5560
5661# IP addresses
5762alias ip=" dig +short myip.opendns.com @resolver1.opendns.com"
58- alias localip="ipconfig getifaddr en1 "
63+ alias localip=" ipconfig getifaddr en0 "
5964alias ips=" ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\" ); print }'"
6065
61- # Enhanced WHOIS lookups
62- alias whois="whois -h whois-servers.net "
66+ # Show active network interfaces
67+ alias ifactive= " ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active' "
6368
6469# Flush Directory Service cache
6570alias flush=" dscacheutil -flushcache && killall -HUP mDNSResponder"
6671
6772# Clean up LaunchServices to remove duplicates in the “Open With” menu
6873alias lscleanup=" /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
6974
70- # View HTTP traffic
71- alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
72- alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
73-
7475# Canonical hex dump; some systems have this symlinked
7576command -v hd > /dev/null || alias hd=" hexdump -C"
7677
77- # OS X has no `md5sum`, so use `md5` as a fallback
78+ # macOS has no `md5sum`, so use `md5` as a fallback
7879command -v md5sum > /dev/null || alias md5sum=" md5"
7980
80- # OS X has no `sha1sum`, so use `shasum` as a fallback
81+ # macOS has no `sha1sum`, so use `shasum` as a fallback
8182command -v sha1sum > /dev/null || alias sha1sum=" shasum"
8283
8384# JavaScriptCore REPL
84- jscbin="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc"
85- [ -e "${jscbin}" ] && alias jsc="${jscbin}"
86- unset jscbin
85+ jscbin=" /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc" ;
86+ [ -e " ${jscbin} " ] && alias jsc=" ${jscbin} " ;
87+ unset jscbin;
8788
8889# Trim new lines and copy to clipboard
8990alias c=" tr -d '\n' | pbcopy"
9091
9192# Recursively delete `.DS_Store` files
9293alias cleanup=" find . -type f -name '*.DS_Store' -ls -delete"
9394
94- # ROT13-encode text. Works for decoding, too! ;)
95- alias rot13='tr a-zA-Z n-za-mN-ZA-M'
96-
97- # Empty the Trash on all mounted volumes and the main HDD
98- # Also, clear Apple’s System Logs to improve shell startup speed
99- alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"
95+ # Empty the Trash on all mounted volumes and the main HDD.
96+ # Also, clear Apple’s System Logs to improve shell startup speed.
97+ # Finally, clear download history from quarantine. https://mths.be/bum
98+ 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'"
10099
101100# Show/hide hidden files in Finder
102101alias show=" defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
@@ -109,9 +108,9 @@ alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && k
109108# URL-encode strings
110109alias urlencode=' python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
111110
112- # Merge PDF files
113- # Usage: `mergepdf -o output.pdf input{1,2,3}.pdf`
114- alias mergepdf='/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py '
111+ # Merge PDF files, preserving hyperlinks
112+ # Usage: `mergepdf input{1,2,3}.pdf`
113+ alias mergepdf=' gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf '
115114
116115# Disable Spotlight
117116alias spotoff=" sudo mdutil -a -i off"
@@ -121,9 +120,8 @@ alias spoton="sudo mdutil -a -i on"
121120# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
122121alias plistbuddy=" /usr/libexec/PlistBuddy"
123122
124- # Ring the terminal bell, and put a badge on Terminal.app’s Dock icon
125- # (useful when executing time-consuming commands)
126- alias badge="tput bel"
123+ # Airport CLI alias
124+ alias airport=' /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'
127125
128126# Intuitive map function
129127# For example, to list all directories that contain a certain file:
@@ -132,16 +130,12 @@ alias map="xargs -n1"
132130
133131# One of @janmoesen’s ProTip™s
134132for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
135- alias "$method"="lwp-request -m '$method'"
133+ alias " ${ method} " =" lwp-request -m '${ method} '"
136134done
137135
138- # Make Grunt print stack traces by default
139- command -v grunt > /dev/null && alias grunt="grunt --stack"
140-
141136# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
142137alias stfu=" osascript -e 'set volume output muted true'"
143- alias pumpitup="osascript -e 'set volume 7'"
144- alias hax="growlnotify -a 'Activity Monitor' 'System error' -m 'WTF R U DOIN'"
138+ alias pumpitup=" osascript -e 'set volume output volume 100'"
145139
146140# Kill all the tabs in Chrome to free up memory
147141# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
@@ -151,42 +145,7 @@ alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v exten
151145alias afk=" /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
152146
153147# Reload the shell (i.e. invoke as a login shell)
154- alias reload="exec $SHELL -l"
155-
156- # Faster npm for europeans
157- command -v npm > /dev/null && alias npme="npm --registry http://registry.npmjs.eu"
158-
159- # databox
160- 161-
162- # Delete recursuve files or folders
163- alias deleteSvnRecursive='find . -name ".svn" -type d -exec rm -rf "{}" \;'
164-
165- # XAMPP, PHP, drush
166- alias pear='/Applications/XAMPP/xamppfiles/bin/pear'
167- alias php='/Applications/XAMPP/xamppfiles/bin/php'
168- alias drush='/Applications/XAMPP/xamppfiles/bin/drush'
169-
170- # Aliases for common drush commands that work in a global context.
171- alias dru='drush'
172- alias ddd='drush drupal-directory'
173- # alias dl='drush pm-download'
174- alias ev='drush php-eval'
175- alias sa='drush site-alias'
176- alias lsa='drush site-alias --local'
177- alias st='drush core-status'
178- alias use='drush site-set'
179-
180- # Aliases for drush commands that work on the current drupal site
181- alias cc='drush cache-clear'
182- alias cca='drush cache-clear all'
183- alias dis='drush pm-disable'
184- alias en='drush pm-enable'
185- alias pmi='drush pm-info'
186- alias pml='drush pm-list'
187- alias rf='drush pm-refresh'
188- alias unin='drush pm-uninstall'
189- alias up='drush pm-update'
190- alias upc='drush pm-updatecode'
191- alias updb='drush updatedb'
192- alias q='drush sql-query'
148+ alias reload=" exec ${SHELL} -l"
149+
150+ # Print each PATH entry on a separate line
151+ alias path=' echo -e ${PATH//:/\\n}'
0 commit comments