Skip to content

Instantly share code, notes, and snippets.

Created August 17, 2021 05:50
What would you like to do?
My comment about .bashrc in **justintv** post (

I created my own version for displaying the git branch in prompt starting from @vankasteelj reply (wrote on Mar 7, 2016).


It is a simple solution that includes branch status color. Take a look:

parse_git_bg() {
  if [[ $(git status -s 2> /dev/null) ]]; then
    echo -e "\033[0;31m"
    echo -e "\033[0;32m"

PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;34m\]@\[\033[0;34m\]\h \w\[$(parse_git_bg)\]$(__git_ps1)\n\[\033[0;32m\]\$\[\033[0m\] 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment