Ubuntu Bash Git Branch Prompt!

# Git branch in prompt.
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}

export PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]:\[\033[32m\]\$(parse_git_branch)\[\033[00m\]\$ "

This is compatible with the default colour prompt in Ubuntu 16.04, put this in you ~/.bashrc.

Original version (non Ubuntu specific)

Leave a Reply

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