Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Created February 9, 2009 17:00
Show Gist options
  • Save bcardarella/60866 to your computer and use it in GitHub Desktop.
Save bcardarella/60866 to your computer and use it in GitHub Desktop.
Pretty Bash Prompt with colored Git branches
# use with .git-completion.sh
# this script will color the branch name RED if it is dirty
function parse_git_dirty {
if [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]]
then
echo "\e[0;31m"
else
echo "\e[0;00m"
fi
}
PS1='\w$(__git_ps1 " (\[$(parse_git_dirty)\]%s\[\e[m\])") \$ '
export PS1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment