Skip to content

Instantly share code, notes, and snippets.

@bryfox
Created December 22, 2010 02:01
Show Gist options
  • Save bryfox/750959 to your computer and use it in GitHub Desktop.
Save bryfox/750959 to your computer and use it in GitHub Desktop.
Add branch names for git & hg repos to command prompt
# add to .bash_profile or somesuch
hg_branch() {
hg branch 2> /dev/null | awk '{print "(hg:"$1")"}'
}
git_branch() {
git branch 2> /dev/null | head -1 | awk '{print "(git:"$2$3")"}'
}
export PS1='\[\033[38m\]\u@\h\[\033[01;32m\] \w \[\033[31m\]$(hg_branch)$(git_branch)\[\033[37m\] $\[\033[00m\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment