- Save https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh as
~/.git-prompt.sh
chmod +x ~/.git-prompt.sh
- Edit
~/.bashrc
and replace fragment with below:
# Load in the git branch prompt script.
source ~/.git-prompt.sh
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]'"\$(__git_ps1)"'\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w'"\$(__git_ps1)"'\$ '
fi
unset color_prompt force_color_prompt