summaryrefslogtreecommitdiff
path: root/12_Prompts.zsh
diff options
context:
space:
mode:
authorHugues Hiegel <hugues.hiegel@qosmos.com>2012-03-07 18:43:12 +0100
committerHugues Hiegel <hugues.hiegel@qosmos.com>2012-03-07 18:43:25 +0100
commit44565988a8345b19f39cd2a4619cd2c0fcecf9a9 (patch)
tree62020bdc2dee72e48bb2925735e6cf82f4667678 /12_Prompts.zsh
parentdac40ba1e286aed29df3f0ac505842be23db600b (diff)
[Prompts] uses vcs_info
Diffstat (limited to '12_Prompts.zsh')
-rw-r--r--12_Prompts.zsh47
1 files changed, 22 insertions, 25 deletions
diff --git a/12_Prompts.zsh b/12_Prompts.zsh
index ba8c7fb..49ed318 100644
--- a/12_Prompts.zsh
+++ b/12_Prompts.zsh
@@ -265,23 +265,19 @@ __update_prompt_elements()
SVNREV=${SVNREV:+$C_$_prompt_colors[doubledot]$_C $C_$SVNSTATUS$_C"r"$SVNREV}
[ "$DEBUG" = "yes" ] && echo
- # get hg status
- [ "$DEBUG" = "yes" ] && echo -n " HG status..."
- HGBRANCH=$(__get_gcl_branch hg)
- [ ! -z "$HGBRANCH" ] && HGBRANCH=" "$HGBRANCH
- [ "$DEBUG" = "yes" ] && echo
-
- # get git status
+ # get VCS status
#
- [ "$DEBUG" = "yes" ] && echo -n " GIT status..."
- GITBRANCH=$(__get_gcl_branch git)
- GITBRANCHSIZE=${#GITBRANCH}
- [ $GITBRANCHSIZE -gt 0 ] && GITBRANCHSIZE=$(($GITBRANCHSIZE))
+ [ "$DEBUG" = "yes" ] && echo -n " Update VCS info..."
+ vcs_info 2>&-
+ VCSROOT=${vcs_info_msg_0_/ */}
+ VCSBRANCH=${vcs_info_msg_0_/$VCSROOT /}
+ VCSROOT=${VCSROOT/$HOME/\~}
+ VCSBRANCHSIZE=0 #TBD
[ "$DEBUG" = "yes" ] && echo
[ "$DEBUG" = "yes" ] && echo -n " Path..."
MY_PATH="%(!.%d.%~)"
- PATHSIZE=$(print -Pn $MY_PATH)
+ CURDIR=$(print -Pn $MY_PATH)
PATHSIZE=${#PATHSIZE}
[ "$DEBUG" = "yes" ] && echo
[ "$DEBUG" = "yes" ] && echo -n " Resize path / gitbranch..."
@@ -291,31 +287,32 @@ __update_prompt_elements()
#minimalpathsize=${#minimalpathsize}
minimalpathsize=10
minimalgitsize=10 # git-abbrev-commit-ish...
- if [ $GITBRANCHSIZE -gt 0 ]
+ if [ $VCSBRANCHSIZE -gt 0 ]
then
- if [ $spaceleft -lt $(( $PATHSIZE + $GITBRANCHSIZE )) ]
+ if [ $spaceleft -lt $(( $PATHSIZE )) ]
then
- CHUNKABLE=${${GITBRANCH/*→/}/←*/}
+ CHUNKABLE=${${VCSBRANCH/*→/}/←*/}
# reduce the git-branch until it is shrinked to $minimalgitsize characters max.
- if [ $GITBRANCHSIZE -gt $minimalgitsize ]
+ if [ $VCSBRANCHSIZE -gt $minimalgitsize ]
then
- GITBRANCHCHUNK=$(( $GITBRANCHSIZE - ($spaceleft - $PATHSIZE) ))
- [ $((${#CHUNKABLE} - $GITBRANCHCHUNK)) -lt $minimalgitsize ] && GITBRANCHCHUNK=$((${#CHUNKABLE} - $minimalgitsize))
+ VCSBRANCHCHUNK=$(( $VCSBRANCHSIZE - ($spaceleft - $PATHSIZE) ))
+ [ $((${#CHUNKABLE} - $VCSBRANCHCHUNK)) -lt $minimalgitsize ] && VCSBRANCHCHUNK=$((${#CHUNKABLE} - $minimalgitsize))
fi
- CHUNKABLE=`print -Pn "%"$(( ${#CHUNKABLE} - $GITBRANCHCHUNK ))">¬>"${CHUNKABLE%\~*}`
+ CHUNKABLE=`print -Pn "%"$(( ${#CHUNKABLE} - $VCSBRANCHCHUNK ))">¬>"${CHUNKABLE%\~*}`
- GITBRANCH=${GITBRANCH/→*←/→$CHUNKABLE←}
+ VCSBRANCH=${VCSBRANCH/→*←/→$CHUNKABLE←}
fi
fi
# then we reduce the path until it reaches the last path element,
- spaceleft=$(($spaceleft - $GITBRANCHSIZE))
+ spaceleft=$(($spaceleft - $VCSBRANCHSIZE))
[ $spaceleft -lt $minimalpathsize ] && spaceleft=$minimalpathsize
- if [ -n "$GITBRANCH" ]
+ if [ -n "$VCSBRANCH" ]
then
- GITBRANCH=$C_$_prompt_colors[soft_generic]$_C${${GITBRANCH/→/$C_"$(__get_git_status)"$_C}/←/$C_$_prompt_colors[soft_generic]$_C}"$(__get_guilt_series)$C_$color[none]$_C"
+ #VCSBRANCH=$C_$_prompt_colors[soft_generic]$_C${${VCSBRANCH/→/$C_"30"$_C}/←/$C_$_prompt_colors[soft_generic]$_C}"$C_$color[none]$_C"
fi
- CURDIR="$C_$_prompt_colors[path]$_C%`echo $spaceleft`<..<"$MY_PATH"%<<$C_$color[none]$_C"
+ [ -n "$VCSROOT" ] && CURDIR=${CURDIR/$VCSROOT*/$VCSROOT}
+ CURDIR="$C_$_prompt_colors[path]$_C%`echo $spaceleft`<..<"$CURDIR"%<<$C_$color[none]$_C"
[ "$DEBUG" = "yes" ] && echo
}
@@ -341,7 +338,7 @@ __two_lines_prompt ()
## Le prompt le plus magnifique du monde, et c'est le mien !
# Affiche l'user, l'host, le tty et le pwd. Rien que ça...
PS1=$AGENTS$MAILSTAT$ERROR$BATTERY$C_$_prompt_colors[bar]$_C$HBAR$DATE"
-"$C_$prompt_color[default]$_C$C_$_prompt_colors[user]$_C"%n"$C_$_prompt_colors[arob]$_C"@"$C_$_prompt_colors[host]$_C"%M"$C_$_prompt_colors[display]$_C"${DISPLAY:+($DISPLAY)} "$CURDIR$CVSTAG$SVNREV$GITBRANCH$HGBRANCH" "$C_$_prompt_colors[dies]$_C"%#"$C_$_prompt_colors[cmd]$_C" "
+"$C_$prompt_color[default]$_C$C_$_prompt_colors[user]$_C"%n"$C_$_prompt_colors[arob]$_C"@"$C_$_prompt_colors[host]$_C"%M"$C_$_prompt_colors[display]$_C"${DISPLAY:+($DISPLAY)} "$CURDIR$VCSBRANCH" "$C_$_prompt_colors[dies]$_C"%#"$C_$_prompt_colors[cmd]$_C" "
}