# Set personal aliases, overriding those provided by oh-my-zsh libs, # plugins, and themes. Aliases can be placed here, though oh-my-zsh # users are encouraged to define aliases within the ZSH_CUSTOM folder. # For a full list of active aliases, run `alias`. # Enable aliases to be sudo’ed alias sudo="sudo " # Shortcuts alias o="open" alias oo="open ." alias e="$EDITOR" alias g="git" alias v="vim" alias gh="github" alias rm="trash" alias x+="chmod +x" alias -- +x="chmod +x" # Easier navigation: .., ..., ~ and - alias ..="cd .." alias cd..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." alias ~="cd ~" # `cd` is probably faster to type though alias -- -="cd -" # mv, rm, cp, gunzip alias mv='mv -v' alias rm='rm -i -v' alias cp='cp -v' alias ungz="gunzip -k" # Trim new lines and copy to clipboard alias trimcopy="tr -d '\n' | pbcopy" alias cask='brew cask' # i <3 u cask alias where=which # sometimes i forget alias brwe=brew #typos # Vagrant aliases alias vag='vagrant' alias vagup='vagrant up' alias vagdestroy='vagrant destroy' alias vagssh='vagrant ssh' alias vaghalt='vagrant halt' # Be nice alias htop='sudo htop' alias hosts='sudo $EDITOR /etc/hosts' # yes I occasionally 127.0.0.1 twitter.com ;) # # Time to upgrade `ls` # # Always use color output for `ls` # 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 # Use coreutils `ls` if possible… hash gls >/dev/null 2>&1 || alias gls="ls" # List all files colorized in long format alias l="ls -l ${colorflag}" # ls options: A = include hidden (but not . or ..), F = put `/` after folders, h = byte unit suffixes alias ls='gls -AFh ${colorflag} --group-directories-first' # List all files colorized in long format, including dot files alias la="ls -la ${colorflag}" # List only directories alias lsd='ls -l | grep "^d"' # `cat` with beautiful colors. requires Pygments installed. # sudo easy_install -U Pygments alias c='pygmentize -O style=monokai -f console256 -g' # IP addresses alias ip="dig +short myip.opendns.com @resolver1.opendns.com" alias localip="ipconfig getifaddr en1" alias myip="ifconfig | grep 'inet ' | grep -v 127.0.0.1 | awk '{print \$2}'" # Copy my public key to the pasteboard alias pubkey="more ~/.ssh/id_rsa.pub | pbcopy | printf '=> Public key copied to pasteboard.\n'" # Flush DNS cache alias flushdns="dscacheutil -flushcache" # # GIT STUFF # # List git branches on the local machine sorted by recent updates, adding a star to remote tracking branches function git_list_branches() { RED="\e[91m"; for branch in $(git branch | sed s/^..//); do time_ago=$(git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $branch --); # Add a red star to mark branches that are tracking something upstream tracks_upstream=$(if [ "$(git rev-parse $branch@{upstream} 2>/dev/null)" ]; then printf "$RED★"; fi); printf "%-53s - %s %s\n" $time_ago $branch $tracks_upstream; done | sort; } # Git aliases alias gss="git status -s" alias gp="git push origin HEAD" alias gpt="git push origin HEAD && git push --tags" alias wip="git commit -m'WIP' . && git push origin HEAD" alias grok="ngrok start rem.jsbin-dev.com static.rem.jsbin-dev.com learn.rem.jsbin-dev.com" alias gl='git log' alias gs='git status' alias gd='git diff' alias gm='git commit -m' alias gma='git commit -am' alias gb='git branch' alias gc='git checkout' alias gra='git remote add' alias grr='git remote rm' alias gbt=git_list_branches alias gpu='git pull' alias gcl='git clone' alias gta='git tag -a -m' alias gf='git reflog' # Undo a `git push` alias undopush="git push -f origin HEAD^:master" # `cd` to Git repo root alias gr='[ ! -z `git rev-parse --show-cdup` ] && cd `git rev-parse --show-cdup || pwd`' #alias gr='git rev-parse 2>/dev/null && cd "./$(git rev-parse --show-cdup)"' # Gist alias gist-paste="gist --private --copy --paste --filename" # gist-paste filename.ext -- create private Gist from the clipboard contents alias gist-file="gist --private --copy" # gist-file filename.ext -- create private Gist from a file # Networking. IP address, dig, DNS alias ip="dig +short myip.opendns.com @resolver1.opendns.com" alias dig="dig +nocmd any +multiline +noall +answer" # View HTTP traffic alias sniff="sudo ngrep -W byline -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 \/.*\"" # Enhanced WHOIS lookups alias whois="whois -h whois-servers.net" # Download file and save it with filename of remote file alias get="curl -O -L" # Recursively delete `.DS_Store` files alias cleanup_dsstore="find . -name '*.DS_Store' -type f -ls -delete" # Disc utils alias diskspace_report="df -P -kHl" alias free_diskspace_report="diskspace_report" # File size alias fs="stat -f \"%z bytes\"" # Empty the Trash on all mounted volumes and the main HDD. # Also, clear Apple’s System Logs & the useless sleepimage to improve shell startup speed alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv $HOME/.Trash; sudo rm -rtv /private/var/log/asl/*.asl; sudo rm /private/var/vm/sleepimage" # Show/hide hidden files in Finder alias showdotfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" alias hidedotfiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" # Show/hide all desktop icons (useful when presenting) alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder" alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder" # Update installed Ruby gems, Homebrew, npm, and their installed packages alias brew_update="brew -v update; brew upgrade --force-bottle --cleanup; brew cleanup; brew cask cleanup; brew prune; brew doctor; npm-check -g -u" alias update_brew_npm_gem='brew_update; npm install npm -g; npm update -g; sudo gem update --system; sudo gem update --no-rdoc --no-ri' # HTTP Requests. One of @janmoesen’s ProTip™s for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do alias "$method"="lwp-request -m '$method'" done