07 Jun

Show current Mercurial branch in shell (like in Git Bash)

hgBranch() {
    if [ -d .hg ]; then
      printf "$1" "$(hg branch)"
    fi
}

export PS1='${USER}@${HOSTNAME}:\w$(hgBranch " [\033[1;31m(%s)\033[0m]")$ '

Leave a Reply

Your email address will not be published. Required fields are marked *