Created
April 27, 2011 08:06
-
-
Save lexaurin/943888 to your computer and use it in GitHub Desktop.
Shows actual git branch on command prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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