This will give you a coloured bash prompt based on the status of the current git branch you are in. (if you are in one)
This is very handy to make sure things are committed or stashed before switching branches.
Add the following three bash snippets to your .bashrc or .bash_profile
The key line in the second function is the PS1 variable. This can be constructed any way you want to.
You just need to insert
_git_prompt (inside of backticks) at the point you want the coloured git status to appear.
Because you are wanting to effectively run a command inside of your PS1 now (via backticks)
you will need to make sure you are setting this via PROMPT_COMMAND instead of
This is what the third code block above is for.