Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.