Skip to content

Instantly share code, notes, and snippets.

@marioestrada
Created February 17, 2011 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marioestrada/831832 to your computer and use it in GitHub Desktop.
Save marioestrada/831832 to your computer and use it in GitHub Desktop.
Shows the current working branch on the prompt with the corresponding revision control software (Mercurial or Git).
# Modify prompt
function bash_git_branch
{
git branch 2> /dev/null | grep \* | python -c "print '[git:'+raw_input()[2:]+']'" 2> /dev/null
}
function bash_hg_branch
{
hg branch 2> /dev/null | python -c "print '[hg:' + raw_input()[0:] + ']'" 2> /dev/null
}
# PS1 = "\h:\W \u\$ "
export PS1="\[\e[1;31m\]\h\[\e[m\]:\[\e[1;34m\]\W \[\e[1;33m\]\$(bash_git_branch)\$(bash_hg_branch)\[\e[m\]\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment