Skip to content

Instantly share code, notes, and snippets.

@juansedo
Created August 17, 2021 05:50
Embed
What would you like to do?
My comment about .bashrc in **justintv** post (https://gist.github.com/justintv/168835)

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

image

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"
  else
    echo -e "\033[0;32m"
  fi
}

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