How to display the Mercurial branch name to bash prompt

To have your current branch name in your bash prompt, just add this code into .bash_profile file from your home directory. [sourcecode language=”bash”] hgBranch () { if [ -d .hg ]; then printf "$1" "$(hg branch)" fi } export PS1=’${USER}@${HOSTNAME}:\w$(hgBranch " [\033[1;31m(%s)\033[0m]")$ ‘ [/sourcecode] Ofcourse, after you edit .bash_profile, you must logout and login again… Continue reading How to display the Mercurial branch name to bash prompt