Customize the BASH prompt to show current git branch and status - ParkinT/mastering_git GitHub Wiki
Add this to the ~/.bashrc
file on your computer for the customized command prompt that shows your current 'git' branch:
[ -z "$PS1" ] && return
function parse_git_dirty
{
git diff --no-ext-diff --quiet --exit-code &> /dev/null || echo "*"
}
function parse_git_branch
{
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
}
export CLICOLOR=1
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$(parse_git_branch)\$ "