raecoo
2010-10-05 17:30:51 +08:00
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})[0m"
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="[31;40mr[0m"
fi
echo $RSLT
}
COL=`expr $COLUMNS - 1`
LINE=''
COUNT=0
while test ${COL} -gt $COUNT
do
let COUNT++
LINE="${LINE}-"
done
export PS1='[0;36m[${COL}D[0;33m[\u:[0;35m\W[0;33m][0;36m$(parse_git_branch)[0;32m
\$ '
[raecoo:edm](master) 三段分别用不同的颜色显示