Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
274 lines (238 sloc) 6.22 KB
# Config files
# aliases
# reload all config files
alias rl="source $DOTFILES/zshrc"
# display aliases
alias al="alias"
# reload aliases
alias arl="source $ALIASFILE"
# edit aliases
alias aed='$EDITOR $ALIASFILE'
# search aliases for pattern
alias ag='alias | grep'
# search processes
alias psg='ps -ef | grep'
# display history
alias hi='history'
# search history
alias hg='history | grep'
# quick cd
# change to dotfiles directory
alias dot="cd $DOTFILES"
alias cust="cd $ZSH_CUSTOM"
alias doc="cd $HOME/Documents"
# Finder
# open files or directories
o(){ open ${1:-.} }
# show hidden files in finder
alias sf="defaults write AppleShowAllFiles TRUE; killall Finder"
# hide hidden files in finder
alias hf="defaults write AppleShowAllFiles FALSE; killall Finder"
alias zshrc="edit $DOTFILES/zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
alias c="clear"
alias l='ls -lAh'
# Git
# Most aliases are added by the oh-my-zsh git plugin
alias gi='git init'
# Display all tracked files
alias gt='git ls-tree -r master --name-only'
# List git-ignored files
alias gig='git ls-files . --ignored --exclude-standard --others'
# List untracked files
alias gut='git ls-files . --exclude-standard --others'
# Git commit all with message
alias gcam='git commit -vam'
# Push to origin
alias gpo='git push origin'
alias gpu='git push -u'
# Fetch
alias gf='git fetch'
# Fetch and merge upstream master
alias gum='git fetch upstream && git merge upstream/master'
# Fetch and merge upstream master
alias gom='git fetch origin && git merge origin /master'
# Show diff of a commit
alias gs='git show'
# Show diff of a commit (filenames only)
alias gsn='git show --name-only'
alias gdc='git diff --cached'
alias st='tig status'
alias i='tig'
# Tree
#always use color
alias tree='tree -C'
alias t='tree'
# show hidden files in tree, excluding .git folder
alias ta='tree -aI ".git"'
# show hidden files in tree, including .git folder
alias tag='tree -a'
alias gsta='git stash'
# Less
alias le="less"
# Tmux
alias tm="tmux"
alias tmr="tmuxinator"
alias tmk="tmux kill-session -t"
alias tmka="killall tmux"
# copy to clipboard
alias tmc="tmux showb | pbcopy"
#kill all tmux sessions
# alias tmk="tmux ls | awk '{print $1}' | sed 's/://g' | xargs -I{} tmux kill-session -t {}"
# Npm
alias ns="npm start"
alias ni="sudo npm install"
# Ruby
alias gmi="sudo gem install"
alias gmin="sudo gem install --no-ri --no-rdoc"
alias sc='script/console'
alias sg='script/generate'
alias sd='script/destroy'
alias migr='rake db:migrate db:test:clone'
alias rvl='rvm list'
alias rvc='rvm current'
alias rvu='rvm use'
alias rvd='rvm default'
alias rvdu='rvm --default use'
alias ss='bundle exec rails server'
alias rc='rails console'
alias rg='rails generate'
alias be='bundle exec'
alias rake='noglob rake'
alias dbm='rake db:migrate'
alias dbs='rake db:seed'
alias dbd='rake db:drop'
alias dbc='rake db:create'
alias rr='bundle exec rake'
alias rsa='bundle exec rake spec:all'
alias rsi='bundle exec rake spec:integration'
alias rst='bundle exec rake teaspoon'
# rspec
alias rsp='bundle exec rspec'
alias rspd='rspec -cfd -t "~js"'
alias rspjs='rspec -c'
alias rspjsd='rspec -cfd'
alias rspw='rspec -c -t wip'
alias rspwd='rspec -cfd -t wip'
# Coffeescript
#compile coffeescript w/ map
alias co="coffee -cm"
#compile coffeescript w/ map and watch
alias cw="coffee -cmw"
# Web shortcuts
alias gml="open"
# Encoding
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"'
# Make all files in dotfiles/bin executable
alias binx="chmod +x $DOTFILES/bin/*"
alias compile-ssh-config='echo -n > ~/.ssh/config && cat $DOTFILES/config/*.ssh > ~/.ssh/config'
# System utilities
# display disk usage in human readable format
alias dfh='df -H'
# show history, sorted by usage
alias hu='historyusage'
historyusage(){ history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -r }
# search hash
alias hshg="hash | grep"
#find file by name
alias f="find . -name "
#start mysql
alias sql="mysql.server start"
#stop mysql
alias ssql="mysql.server stop"
# Browser shortcuts
# Open github (must set GH_USERNAME variable)
# Accepts argument for project
alias gh=github
github(){ open "$GH_USERNAME/$@" }
alias hb='hub browse'
# functions
# google search from command line
# Ex: ggl this is a search, no quotes necessary
function ggl() {
encodedarg=`urlencode $arg`
open "$encodedarg"
# make a directory and cd into it
mkcd() { mkdir -p "$@" && cd "$_"; }
# open file in editor. if file doesnt exist, create it
# TODO: ensure that folder structure gets created automatically if it doesnt exist
# BUG: does not work with Vim
edits() {
if ! [ -f "$@" ]
echo "Created $@"
touch "$@"
$($EDITOR $@)
function new(){
mkcd $@ && git init && edit
# open editor (accepts dir/file as argument, otherwise opens at current dir)
edit(){ $($EDITOR ${@:-'.'}) }
alias e="edit"
# backup files/folders
while [ -f "$name" ] || [ -d "$name" ]; do
echo "$name exists"
cp -R "$@" "$name"
git diff "$@" --name-only
while [ "true" ]
clear && tree "$@"
sleep 1
# find and replace
# Usage: find_replace find_str replace_str dir
# mac sed treats -i differently than gnu sed
if [ `uname` = 'Darwin' ]; then
grep -r -l "$1" ${3-.} | xargs -t sed -i '' s/$1/$2/g
grep -r -l "$1" ${3-.} | xargs -t sed -i s/$1/$2/g
# create file and corresponding spec in rails project
edits $@
spec_file=`echo $@ | sed s/app/spec/ | sed s/\.rb/_spec\.rb/`
edits $spec_file
alias ews="edit_with_spec"
# Note taking
touch $NOTEDOC
cat -n $NOTEDOC
echo $@ >> $NOTEDOC
sed -i.bak "$@d" "$NOTEDOC"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && . "$NVM_DIR/" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion