Skip to content

Instantly share code, notes, and snippets.

@juansedo
Created August 17, 2021 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juansedo/b674e1fbed816dae8b8858d7f7847027 to your computer and use it in GitHub Desktop.
Save juansedo/b674e1fbed816dae8b8858d7f7847027 to your computer and use it in GitHub Desktop.
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