Git command prompt awesomeness

In my OS X terminal, I use a two-line command prompt that shows me what git branch I'm on, and whether or not I have uncommitted changes.

Here you'll see that I'm on the master branch. The red astrix denotes uncommitted changes (as shown by git status). You'll see that after comitting the changes, the astrix goes away.

As you can imagine, this is super useful.

Here's the relevant lines in my .bash_profile to make it happen.

export TERM=xterm-256color

MAGENTA=$(tput setaf 9)
ORANGE=$(tput setaf 172)
YELLOW=$(tput setaf 190)
PURPLE=$(tput setaf 141)
BOLD=$(tput bold)
RESET=$(tput sgr0)

export MAGENTA
export ORANGE
export YELLOW
export PURPLE
export BOLD
export RESET

function parse_git_dirty() {
  [[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && echo "$MAGENTA*$RESET"

function parse_git_branch() {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"

export PS1="\[${BOLD}${ORANGE}\]\u \[$YELLOW\]\w\[$RESET\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on branch: \")\[$PURPLE\]\$(parse_git_branch)\n> \[$RESET\]"