Skip to content

Instantly share code, notes, and snippets.

@friggeri
Created February 1, 2011 01:58
Show Gist options
  • Save friggeri/805269 to your computer and use it in GitHub Desktop.
Save friggeri/805269 to your computer and use it in GitHub Desktop.
function git_prompt {
branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"`
if [ -n "$branch" ]; then
case `git status 2> /dev/null | tail -n1` in
"nothing to commit (working directory clean)")
color="01;33m";;
"nothing added to commit but untracked files present (use \"git add\" to track)")
color="01;35m";;
*)
color="01;31m";;
esac
branch="\033[$color$branch\033[00m"
echo -e " [$branch]"
fi;
}
PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$(git_prompt)\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment