Skip to content

Instantly share code, notes, and snippets.

@jpgneves
Created November 8, 2011 16:47
Show Gist options
  • Select an option

  • Save jpgneves/1348326 to your computer and use it in GitHub Desktop.

Select an option

Save jpgneves/1348326 to your computer and use it in GitHub Desktop.
Output colorized git branch (red = dirty, green = clean)
function colorize_git_status {
git diff --quiet HEAD &> /dev/null
[[ $? == 1 ]] && echo -e '\033[0;31m' || echo -e '\033[0;32m'
}
export PS1="\\h:\\w\[\$(colorize_git_status)\][\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)]\\[\\033[0m\\]\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment