#!/usr/bin/env bash alias aliases="vim $HOME/.aliases" # Always enable colored `grep` output` alias grep="grep --color=auto" alias fgrep="fgrep --color=auto" alias egrep="egrep --color=auto" # Easier navigation: .., ..., ...., ....., ~ and - alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." alias ~="cd $HOME" # `cd` is probably faster to type though alias -- -="cd -" # Shortcuts alias dbox="cd $HOME/Dropbox" alias dls="cd $HOME/Downloads" alias dotfiles="cd $HOME/dotfiles" alias dtop="cd $HOME/Desktop" alias lib="cd $HOME/Library" alias work="cd $HOME/Work" alias repos="cd $HOME/repos" alias proj="cd $HOME/projects" alias dwork="cd $HOME/Dropbox/Work" alias drepos="cd $HOME/Dropbox/repos" alias dcode="cd $HOME/Dropbox/code" alias dproj="cd $HOME/Dropbox/projects" alias g="git" alias v="vim" alias ungz="gunzip -k" alias where=which alias cask='brew cask' # Always use color output for `ls` if hash gls 2>/dev/null; then # use gls from gnu coreutils colorflag="--color" 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:' eval $(gdircolors -b "$HOME/.dircolors") alias ls="command gls ${colorflag}" else # use good old bsd ls colorflag="-G" export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx' alias ls="command ls ${colorflag}" fi; # List all files colorized alias ll="ls -l ${colorflag}" # List all files colorized in long format alias l="ls -lF ${colorflag}" # List all files colorized in long format, including dot files alias la="ls -laF ${colorflag}" # List only directories alias lsd="ls -l | grep --color=never '^d'" # 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 ' # mv, rm, cp, etc alias mv='mv -v' alias rm='rm -i -v' alias cp='cp -v' alias chmox='chmod -x' # Silver Searcher alias ag='ag -f --hidden' # File size (quick) alias fsq="stat -f \"%z bytes\"" # Hosts alias hosts='sudo $EDITOR /etc/hosts' # 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; \ npm cache clean; \ 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' alias chromenocors='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="$HOME/tmp/james_bonds_browser" --disable-web-security -h &' # 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 }'" # wget sucks with certificates. Let's keep it simple. #alias wget="curl -O" # Show active network interfaces alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'" # 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 \/.*\"" # Flush Directory Service cache alias flushdns="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" # Misc. alias weather="curl -4 http://wttr.in/$1" alias shrug="echo '¯\_(ツ)_/¯' | pbcopy" alias bell="tput bel" # ring terminal bell # 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 dscleanup="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 $HOME/.Trash; \ sudo rm -rfv /private/var/log/asl/*.asl; \ sqlite3 $HOME/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent' \ " alias kaf="killall Finder" # Show/hide hidden files in Finder alias showhidden="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" alias hidehidden="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" # Airport CLI alias alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport' # Intuitive map function # For 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 # npm alias ni="npm install" alias npmg="npm list -g --depth=0 2>/dev/null" alias npml="npm list --depth=0 2>/dev/null" alias npmog="npm outdated -g --depth=0" alias npmug="npm update -g" alias npmol="npm outdated --depth=0" alias npmrns="npm rebuild node-sass --force" # Sequel Pro alias sequel="LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN=y /Applications/Sequel\ Pro.app/Contents/MacOS/Sequel\ Pro" # Make Grunt print stack traces by default command -v grunt > /dev/null && alias grunt="grunt --stack" # Rails alias be="bundle exec " alias bi="bundle install" alias rc="bundle exec rails c" alias rlogs="less log/development.log" alias rdbm="be rake db:migrate && rdbmt" alias rdbmd="be rake data:migrate" alias rdbmt="RAILS_ENV=test be rake db:migrate" # Vagrant alias vg="vagrant global-status" alias vgup="vagrant up" alias vghalt="vagrant halt" alias vgssh="vagrant ssh" alias vgreload="vagrant reload" alias vgrebuild="vagrant destroy --force && vagrant up" # 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 # [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill" # 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}"