Skip to content

Instantly share code, notes, and snippets.

@adamcooke
Created October 16, 2009 12:29
Show Gist options
  • Save adamcooke/211786 to your computer and use it in GitHub Desktop.
Save adamcooke/211786 to your computer and use it in GitHub Desktop.
EDITOR="mate -w"
export GIT_EDITOR="mate -w"
# Put git branch in my prompt.
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\[\1\]/'
}
export PS1='\[\033[01;33m\]\u@\h\[\033[00m\]:\[\033[0;31m\]\w\[\033[00m\]\[\033[37m\]$(parse_git_branch)\[\033[00m\]\$ '
export PATH="/usr/local/mysql/bin/:/opt/local/bin:/opt/local/sbin:/Users/adam/.gem/ruby/1.8/bin:$PATH"
## Development aliases
alias g="git "
alias m="mate ."
alias dbm="rake db:migrate"
alias dbr="rake db:rollback"
alias sg="./script/generate "
alias sc="./script/console "
alias mr="mongrel_rails"
alias mrr="mongrel_rails restart"
alias com="git add . && git commit -a && git pull && git push"
alias devlog="tail -f -n 500 log/production.log log/development.log"
alias res="touch tmp/restart.txt"
# Codebase deployment command
alias rrd="rake remote:deploy"
# Local nginx commands
alias nginx_stop="sudo killall nginx"
alias nginx_start="sudo /opt/nginx/sbin/nginx"
alias nginx_restart="sudo killall nginx && sudo /opt/nginx/sbin/nginx"
# Quick access for testing XML and JSON APIs with curl
alias curlxml="curl -H 'Accept: application/xml' -H 'Content-type: application/xml' "
alias curljson="curl -H 'Accept: application/json' -H 'Content-type: application/json' "
# Quick access to clear my local cache because I can never remember this command for some reason.
alias clear_cache="dscacheutil -flushcache"
# Clear local cache and that of the local caching server.
clear_all_caches () {
dscacheutil -flushcache
ssh root@fred.atechmedia.lan "/etc/init.d/bind9 stop && /etc/init.d/bind9 start"
}
# Defunkt's cool little cd script for remembering your last directory
pathed_cd () {
if [ "$1" == "" ]; then
cd
else
cd "$1"
fi
pwd > ~/.cdpath
}
alias cd="pathed_cd"
if [ -f ~/.cdpath ]; then
cd $(cat ~/.cdpath)
fi
# Quick command to update local bash_login with the latest from this gist
updatebashconf () {
mv ~/.bash_login ~/.bash_login.bak
echo 'Getting latest bash file from Github'
raw_url=`curl -sq http://gist.github.com/211786 | grep -E -o "<a href\=\".*\">raw<\/a>" | sed "s/<a href=\"//" | sed "s/\">raw<\/a>//"`
echo "Getting raw file from $raw_url"
curl -sq http://gist.github.com$raw_url > ~/.bash_login
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment