summaryrefslogtreecommitdiff
path: root/12_Prompts.zsh
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2012-03-08 12:29:44 +0100
committerHugues Hiegel <hugues.hiegel@qosmos.com>2012-03-08 13:35:08 +0100
commitdc2abe342ec7e0d674ea7c510566aba5a6b37f1e (patch)
tree0266c374f5e978e6b2992974027a6561fe5d6573 /12_Prompts.zsh
parentf61008d24c79c105c77682b2f7ce1c40b32744dc (diff)
Get backs vcs_info.
Diffstat (limited to '12_Prompts.zsh')
-rw-r--r--12_Prompts.zsh78
1 files changed, 26 insertions, 52 deletions
diff --git a/12_Prompts.zsh b/12_Prompts.zsh
index f927813..857e042 100644
--- a/12_Prompts.zsh
+++ b/12_Prompts.zsh
@@ -238,49 +238,20 @@ __update_prompt_elements()
## Second line of prompt : don't let the path garbage the entire line
##
- # get cvs tag
+ # get VCS status
#
- CVSTAG=""
- [ "$DEBUG" = "yes" ] && echo -n " CVS status..."
- if [ -d CVS ]
- then
- CVSTAG=$(test -e CVS/Tag && cat CVS/Tag || basename $(cat CVS/Root 2>&- || echo "HEAD") )
- CVSTAG=${CVSTAG:+ $C_$_gcl_colors[uptodate]$_C$CVSTAG}
- fi
-
- # get svn status
- #
- [ "$DEBUG" = "yes" ] && echo -n " SVN status..."
- SVNREV=$(LC_ALL=C svn info 2>&- $PWD | awk '/^Revision: / {print $2}')
- SVNREVSIZE=${#${SVNREV:+ r$SVNREV}}
- if [ "$SVNREV" != "" ]
- then
- if [ ! -z "$CHECK_SVN_STATUS" ]
- then
- SVNSTATUS="$(svn diff 2>&-)"
- SVNSTATUS=${${SVNSTATUS:+$_gcl_colors[changed]}:-$_gcl_colors[uptodate]}
- fi
- fi
- 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
- #
- [ "$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_1_}
+ VCSROOT=${VCSROOT/$HOME/\~}
+ VCSSUBDIR=${vcs_info_msg_2_}
+ VCSBRANCH=${vcs_info_msg_0_}
+ 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..."
@@ -290,34 +261,35 @@ __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"
- [ "$DEBUG" = "yes" ] && echo
- VCSBRANCH=$CVSTAG$SVNREV$GITBRANCH$HGBRANCH
+ [ -n "$VCSROOT" ] && CURDIR=${CURDIR/$VCSROOT*/$VCSROOT}
+ CURDIR="$C_$_prompt_colors[path]$_C%`echo $spaceleft`<..<"$CURDIR"%<<$C_$color[none]$_C"
+ [ "$VCSSUBDIR" != "." ] && CURDIR+=$C_$color[cyan]";"$color[bold]$_C"/"$C_$_prompt_colors[path]$_C$VCSSUBDIR
+ [ "$DEBUG" = "yes" ] && echo
}
__redefine_prompt ()
@@ -337,6 +309,8 @@ __yeah_prompt ()
PS1=$C_$prompt_color[default]$_C$C_$_prompt_colors[user]$_C"%n"$C_$_prompt_colors[arob]$_C"@"$C_$_prompt_colors[host]$_C"%m "$CURDIR" "$C_$_prompt_colors[dies]$_C">"$C_$_prompt_colors[cmd]$_C" "
}
+setopt PROMPT_SUBST
+
__two_lines_prompt ()
{
__cmd_exists __compilation && __compilation