Skip to content

Instantly share code, notes, and snippets.

@rjp
Created September 22, 2010 13:20
Show Gist options
  • Save rjp/591643 to your computer and use it in GitHub Desktop.
Save rjp/591643 to your computer and use it in GitHub Desktop.
function parse_git_branch {
xx=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)
/(\1)/")
echo "$xx"
}
function check_git_changes {
git diff --quiet 2>/dev/null
if [ $? -ne 0 ]; then
tput setaf 1 # red
else
tput setaf 2 # green
fi
}
PS1="$PS1\$(check_git_changes)\$(parse_git_branch)\[\033[0m\]\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment