Skip to content

Instantly share code, notes, and snippets.

@heycarsten
Forked from anonymous/snippet.sh
Created January 16, 2009 19:26
Show Gist options
  • Save heycarsten/48067 to your computer and use it in GitHub Desktop.
Save heycarsten/48067 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