Second Brain

My .bash-profile

Posted at — Apr 18, 2020

This is a well-trod topic - search for “add git branch to bash prompt” or “add colors to git prompt” - but it’s useful to me.

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

export PS1="\[\033[32m\]\d \t \[\033[36m\]\u@\H:\[\033[33m\]\w\[\033[32m\]\$(parse_git_branch)\[\033[00m\]$ "