Skip to content

Instantly share code, notes, and snippets.

@bermi
Created January 12, 2011 19:47
Show Gist options
  • Save bermi/776751 to your computer and use it in GitHub Desktop.
Save bermi/776751 to your computer and use it in GitHub Desktop.
Show your git or hg branch name on your MacOS prompt by adding this to your ~/.profile
parse_git_branch (){
[`pwd | grep "work|Sites|Projects"` != ""] && git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(git:\1)/'
}
parse_hg_branch() {
[`pwd | grep "work|Sites|Projects"` != ""] && hg branch 2> /dev/null | sed -e 's/\(.*\)/(hg:\1)/'
}
PS1='\[\033[0;33m\]\w\[\033[00m\]\[\033[01;00m\]$(parse_git_branch)$(parse_hg_branch): '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment