-
-
Save finwe/4205225 to your computer and use it in GitHub Desktop.
Shows current git branch&status on command prompt
This file contains hidden or 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 (modified by Dundee & Finwe) | |
export PSORIG="$PS1" | |
function gitbranch() { | |
branch="$(git branch 2>/dev/null | grep '*' | cut -d" " -f2-)" | |
dirty="$(git status -s 2>/dev/null)" | |
if [ -n "$dirty" ] ; then | |
color="1;33m" | |
else | |
color="0;33m" | |
fi | |
if [ -n "$branch" ] ; then | |
export PS1=$PSORIG$(echo -en "\[\033[$color\]$branch\[\033[0;33m\] > \[\033[00m\]") | |
else | |
export PS1="$PSORIG" | |
fi | |
} | |
PROMPT_COMMAND="gitbranch" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment