1 2 3 4 5 | function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\[\033[01;32m\]\u@\h {\[\033[01;34m\]\w\$(parse_git_branch)\[\033[01;32m\]} \[\033[01;34m\]\$\[\033[00m\] "
|
x
Notes
This script detects if you are in a git repo and adds the current branch to your PS1
{~} $
{~} $ cd repo
{~/repo(master)} $