Skip to content

Instantly share code, notes, and snippets.

@oliverbarnes
Created July 24, 2011 16:32
Show Gist options
  • Save oliverbarnes/1102795 to your computer and use it in GitHub Desktop.
Save oliverbarnes/1102795 to your computer and use it in GitHub Desktop.
.bashrc with git branch parsing, rvm scripts and bunch of aliases for git/rails workflow
if [ -f /etc/bashrc ]; then
. /etc/bashrc # --> Read /etc/bashrc, if present.
fi
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/mongodb/bin:$PATH"
export RUBYLIB=".:test:$RUBYLIB"
export EDITOR='mate'
export HISTFILESIZE=10000
export HISTIGNORE="&:[ ]*:exit" # - ignore duplicate commands, commands starting with spaces, and the exit command
if [[ -s ~/.rvm/scripts/rvm ]] ;
then source ~/.rvm/scripts/rvm ;
fi
if [[ -s ~/.rvm/config/default ]] ; then
source ~/.rvm/config/default #missing??
fi
alias rvmd='rvm default'
PS1="\h[\$(~/.rvm/bin/rvm-prompt v g)]:\W\$(parse_git_branch) $"
# http://www.silassewell.com/blog/2009/03/08/profile-management-with-git-and-github/
alias config='git --git-dir=$HOME/.config.git/ --work-tree=$HOME'
alias mateb='mate ~/.bashrc'
alias editbash='mate ~/.bashrc'
alias srcbash='source ~/.bashrc'
alias l='ls -alFGh'
alias ss='script/server'
alias csl='script/console'
alias devlog='tail -n 300 log/development.log'
alias cukelog='tail -n 300 log/cucumber.log'
alias cukelogf='tail -f log/cucumber.log'
alias migclon='rake db:migrate; rake db:test:clone'
alias gst='git status'
alias gc='git commit -m '
alias gca='git commit -a -m '
alias gp='git push origin master'
alias gpull='git pull origin master'
alias go='git checkout '
alias ga='git add '
alias gall='git add .'
alias gdif='git diff '
alias deployall='git push origin master; git push heroku-development master; git push heroku-staging master; git push heroku-production master'
# mongo
alias rmmongolock='rm -rf db/mongo/mongod.lock'
alias startmongo='rmmongolock; rake mongo:start'
alias flushdns='sudo dscacheutil -flushcache'
#cucumber + rspec
alias spk='spork cucumber & spork &'
alias grepspk='ps aux | grep spork'
alias cuc='cucumber'
#projects
alias sbcd='cd ~/Sites/allbabble'
alias editsb='sbcd; redcar .'
alias sbmongo='sbcd; bundle exec rake mongo:start'
alias sbss='sbcd; ss'
alias startsb='sbcd; sbmongo; sbss'
alias cdhh='cd ~/Sites/hobby_hunter'
alias starthh='cdhh; startmongo; rails server'
alias edithh='cdhh; redcar .'
@peterchappell
Copy link

Thanks for sharing this Oliver.

A friend of mine set up this in my bash profile so that I can see what the aliases execute - which is something I quite like:

# echo and run
function er {
echo $1
$1
}

So that then I can go something like:

alias bunrake="er \"bundle exec rake\""
alias rmmongolock="er \"rm -rf db/mongo/mongod.lock\""
alias startmongo="er \"rmmongolock; bundle exec rake mongo:start\""

@oliverbarnes
Copy link
Author

pretty cool, I'm going to give it a run. does your friend know how to get a listing of aliases available? I keep opening .bashrc each time to check, it'd be great to just do "list_aliases" or something like that

@darylyu
Copy link

darylyu commented Nov 18, 2011

Kind of late to the party, but you could make an alias that greps your .bashrc for "alias".

alias list_aliases='grep alias ~/.bashrc'

@oliverbarnes
Copy link
Author

that does it :) thanks dude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment