Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Submitting vcs_info function



On Wed, Sep 17, 2008 at 10:32:42PM +0200, Frank Terbeck wrote:
> +If you plan to use the information from var(vcs_info) in your prompt (which
> +is its primary use), you need to enable the tt(PROMPT_SUBST) option.

I don't think that this claim is accurate.


Index: Functions/Prompts/prompt_clint_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_clint_setup,v
retrieving revision 1.9
diff -u -r1.9 prompt_clint_setup
--- Functions/Prompts/prompt_clint_setup	17 May 2008 22:42:17 -0000	1.9
+++ Functions/Prompts/prompt_clint_setup	21 Sep 2008 09:07:53 -0000
@@ -15,6 +15,8 @@
   local -A pc
   local p_date p_tty p_plat p_ver p_userpwd p_apm p_shlvlhist p_rc p_end p_win
 
+  autoload -Uz vcs_info
+
   pcc[1]=${1:-'red'}
   pcc[2]=${2:-'cyan'}
   pcc[3]=${3:-'green'}
@@ -36,7 +38,7 @@
   [[ -n "$WINDOW" ]] && p_win="$pc['\(']%F{$pcc[4]}$WINDOW$pc['\)']"
 
   p_userpwd="$pc['<']%F{$pcc[3]}%n@%m$p_win%F{$pcc[5]}:%F{$pcc[4]}%~$pc['>']"
-  p_git="%(2v.-%U%2v%u-.)"
+  p_vcs="%(2v.%U%2v%u.)"
 
   p_shlvlhist="%fzsh%(2L./$SHLVL.) %B%h%b "
   p_rc="%(?..[%?%1v] )"
@@ -46,7 +48,7 @@
 
   prompt="$p_date$p_tty$p_plat$p_ver
 $p_userpwd
-$p_shlvlhist$p_rc$p_git$p_end"
+$p_shlvlhist$p_rc$p_vcs$p_end"
   PS2='%(4_.\.)%3_> %E'
 
   add-zsh-hook precmd prompt_clint_precmd
@@ -63,9 +65,8 @@
 
   [[ -o interactive ]] && jobs -l
 
-  git_dir=$(git-rev-parse --git-dir 2> /dev/null) || return
-  git_ref=$(git-symbolic-ref HEAD 2> /dev/null) || git_ref="(no branch)"
-  psvar[2]=${git_ref#refs/heads/}
+  vcs_info
+  [[ -n $vcs_info_msg_0_ ]] && psvar[2]="$vcs_info_msg_0_"
 }
 
 prompt_clint_setup "$@"



Messages sorted by: Reverse Date, Date, Thread, Author