Skip to content

Instantly share code, notes, and snippets.

@antris
Created January 18, 2012 07:12
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 antris/1631742 to your computer and use it in GitHub Desktop.
Save antris/1631742 to your computer and use it in GitHub Desktop.
Show git or Mercurial branch in command prompt
hg_branch() {
test -e .hg/branch && echo " hg:$(cat .hg/branch)"
}
git_branch() {
test -e .git && git branch | grep \* | awk '{ printf " git:" substr($0, index($0,$2)) }'
}
export PS1='\h:\w$(hg_branch)$(git_branch) $ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment