Skip to content

Instantly share code, notes, and snippets.

@robin
Created November 4, 2009 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robin/226152 to your computer and use it in GitHub Desktop.
Save robin/226152 to your computer and use it in GitHub Desktop.
parse_git_branch() {
RSLT=''
GIT_BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* //'`
if [ "$GIT_BRANCH" ]
then
GIT_STATUS=`git status 2> /dev/null | grep 'working directory clean'`
CLR='2'
if [ "$GIT_STATUS" ]
then
CLR='2'
else
CLR='1'
fi
RSLT="[3${CLR};40m[${GIT_BRANCH}]"
fi
echo $RSLT
}
parse_git_remote_status() {
RSLT=''
GIT_REMOTE_STATUS=`git status 2>/dev/null | grep 'Your branch is ahead of'`
if [ "$GIT_REMOTE_STATUS" ]
then
RSLT="r"
fi
echo $RSLT
}
COL=`expr $COLUMNS - 1`
LINE=''
COUNT=0
while test ${COL} -gt $COUNT
do
let COUNT++
LINE="${LINE}─"
done
export PS1='┌${LINE}[${COL}D────[\u@\h]─────[\t]─────[\W]─────$(parse_git_branch)───$(parse_git_remote_status)
└──> \$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment