Skip to content

Instantly share code, notes, and snippets.

@seanhandley
Created October 12, 2010 14:40
Show Gist options
  • Save seanhandley/622269 to your computer and use it in GitHub Desktop.
Save seanhandley/622269 to your computer and use it in GitHub Desktop.
# Get the current branch of the current git project
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
# Get the current Gemset
function parse_rvm_gemset {
gemset=$(rvm gemset name 2> /dev/null)
echo ""${gemset}""
}
# Get the curent Ruby version
function parse_ruby_version {
ruby=$(ruby -v | perl -n -e '/(\d\.\d\.\d)/ && print "$1\n"' 2> /dev/null) || return
echo ""${ruby}""
}
# Set Bash prompt to include the current branch, ruby version and gemset
PS1="\$(date +%H:%M) \w \$(parse_ruby_version)@\$(parse_rvm_gemset) \$(parse_git_branch)\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment