jxson
9/21/2011 - 6:52 PM

Git info in your `bash` prompt like ~/Code/haiku (trusting) ☠

Git info in your bash prompt like ~/Code/haiku (trusting) ☠

export COLOR_NONE='\[\e[0m\]' # No Color
export COLOR_LIGHT_PURPLE='\[\e[1;35m\]'

# Get the name of the branch we are on
git_prompt_info() {
  branch_prompt=$(__git_ps1)
  if [ -n "$branch_prompt" ]; then
    status_icon=$(git_status)
    echo $branch_prompt $status_icon
  fi
}

# Show character if changes are pending
git_status() {
  if current_git_status=$(git status | grep 'added to commit' 2> /dev/null); then
    echo "☠"
  fi
}


PS1='\u@\h: \w $(git_prompt_info " (%s)")\n'$COLOR_LIGHT_PURPLE'→ '$COLOR_NONE