Skip to content

Instantly share code, notes, and snippets.

@seanhandley
Created October 15, 2010 10:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save seanhandley/627971 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/}")"
}
#Gemset
function parse_rvm_gemset {
gemset=$(rvm gemset name 2> /dev/null) || return
gemset=`echo -e ${gemset}` || return
if [ -n "$gemset" ]; then
echo ""@${gemset}"";
fi
}
#Ruby
function parse_ruby_version {
ruby=$(ruby -v | perl -n -e '/(\d\.\d\.\d)/ && print "$1\n"' 2> /dev/null) || return
enterprise=$(ruby -v | perl -n -e '/(Enterprise)/ && print "ree\n"' 2> /dev/null)
if [ -z "$enterprise" ]; then
echo ""${ruby}"";
else
echo ""${enterprise}"";
fi
}
# Define some colours
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
CYAN="\[\033[0;34m\]"
# Set Bash prompt to include the current branch, ruby and gemsets and be pretty
PS1="$RED\$(date +%H:%M) \w $CYAN\$(parse_ruby_version)\$(parse_rvm_gemset)$YELLOW \$(parse_git_branch)$GREEN\$ "
@ChuckJHardy
Copy link

Jolly Good Show...

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