Skip to content

Instantly share code, notes, and snippets.

@lexaurin
Created April 27, 2011 08:04
Show Gist options
  • Save lexaurin/943887 to your computer and use it in GitHub Desktop.
Save lexaurin/943887 to your computer and use it in GitHub Desktop.
Shows actual git branch on command prompt
#GIT bash by HABR
export PSORIG="$PS1"
function GITCHECK() {
STATUS=$(git status 2> /dev/null)
if [ -n "$STATUS" ] ; then
BRANCH="$(echo "$STATUS" | head -n1 | awk '{print $4}')"
export PS1=$PSORIG$(echo -en "\[\033[01;33m\]$BRANCH > \[\033[00m\]")
else
export PS1="$PSORIG"
fi
}
PROMPT_COMMAND="GITCHECK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment