Skip to content

Instantly share code, notes, and snippets.

Created January 16, 2009 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save anonymous/48066 to your computer and use it in GitHub Desktop.
Save anonymous/48066 to your computer and use it in GitHub Desktop.
parse_git_branch() {
RSLT=''
GIT_BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' | awk '{print $2}'`
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
}
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)───
└──> \$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment