Skip to content

Instantly share code, notes, and snippets.

@lexaurin
Created April 27, 2011 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lexaurin/943888 to your computer and use it in GitHub Desktop.
Save lexaurin/943888 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