I came across a neat way of always being aware of what Git branch you’re working on: just show it in your bash prompt. I like the idea, but the way it’s shown gives you a completely new prompt, overwriting your existing configuration. I changed it a bit and came up with this:

function parse_git_branch_and_add_brackets {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\[\1\]/'
PS1="$PS1\[33[0;31m\]\$(parse_git_branch_and_add_brackets)\[33[0m\]\$ "

This will take your original bash prompt and add the [branch] information to the end, like this: