From b26616140d397b756bbccb5ae295b0af6bc788dd Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Thu, 9 Jul 2009 11:16:11 +0200 Subject: [Prompt] better size calculation for git-rebase, and better cvs name guess --- 12_Prompts.zsh | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to '12_Prompts.zsh') diff --git a/12_Prompts.zsh b/12_Prompts.zsh index 890cee1..e350980 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -233,7 +233,7 @@ update_prompt() [ "$DEBUG" = "yes" ] && echo -n " CVS status..." if [ -d CVS ] then - CVSTAG=$(cat CVS/Tag) + CVSTAG=$(test -e CVS/Tag && cat CVS/Tag || basename $(cat CVS/Root 2>&- || echo "HEAD") ) CVSTAG=${CVSTAG:+ $C_$prompt_colors[up_to_date]$_C$CVSTAG} fi @@ -278,19 +278,28 @@ update_prompt() if [ $spaceleft -lt $(( $PATHSIZE + $GITBRANCHSIZE )) ] then local unbreakablegittail - # reduce the git-branch until it is shrinked to $minimalgitsize characters max. - - if [ $GITBRANCH[-1] = ")" ] - then - unbreakablegittail=${${(M)GITBRANCH%\~*}} - [ "$unbreakablegittail" = "" -a $GITBRANCHSIZE -gt $minimalgitsize ] && unbreakablegittail=")" - fi - if [ $GITBRANCHSIZE -gt $minimalgitsize ] + if [ "$(echo $GITBRANCH | grep "^\[rebase ")" = "" ] then - GITBRANCHSIZE=$(( $spaceleft - $PATHSIZE )) - [ $GITBRANCHSIZE -lt $minimalgitsize ] && GITBRANCHSIZE=$minimalgitsize + # reduce the git-branch until it is shrinked to $minimalgitsize characters max. + + if [ $GITBRANCH[-1] = ")" ] + then + unbreakablegittail=${${(M)GITBRANCH%\~*}} + [ "$unbreakablegittail" = "" -a $GITBRANCHSIZE -gt $minimalgitsize ] && unbreakablegittail=")" + fi + if [ $GITBRANCHSIZE -gt $minimalgitsize ] + then + GITBRANCHSIZE=$(( $spaceleft - $PATHSIZE )) + [ $GITBRANCHSIZE -lt $minimalgitsize ] && GITBRANCHSIZE=$minimalgitsize + fi + GITBRANCH=`print -Pn "%"$(($GITBRANCHSIZE - ${#unbreakablegittail}))">..>"${GITBRANCH%\~*}${unbreakablegittail:+"%"${#unbreakablegittail}"<<"$GITBRANCH}` + else + + # + # TODO : réduire la taille du hash, s'il y en a un. + # + fi - GITBRANCH=`print -Pn "%"$(($GITBRANCHSIZE - ${#unbreakablegittail}))">..>"${GITBRANCH%\~*}${unbreakablegittail:+"%"${#unbreakablegittail}"<<"$GITBRANCH}` fi fi # then we reduce the path until it reaches the last path element, -- cgit v1.2.3