Skip to content

Instantly share code, notes, and snippets.

@mgalushka
Created October 23, 2014 00:18
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 mgalushka/7e13304578b66e650449 to your computer and use it in GitHub Desktop.
Save mgalushka/7e13304578b66e650449 to your computer and use it in GitHub Desktop.
Display branch/bookmark for both git/mercurial in command prompt
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
function hg_branch() {
#hg branch 2> /dev/null | awk '{ printf "\033[37;0m\033[35;40m" $1 }'
hg bookmarks 2> /dev/null | awk '/\*/ { printf " (" $2 ")"}'
}
PS1="$GREEN\u@\h$NO_COLOR:\w$YELLOW\$(parse_git_branch)$YELLOW\$(hg_branch)$NO_COLOR\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment