Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: vcs_info problem
- X-seq: zsh-users 13482
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: vcs_info problem
- Date: Sun, 23 Nov 2008 23:26:58 +0100
- In-reply-to: <20081123220446.GA8594@xxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20081123213233.GA7984@xxxxxxxxxxxx> <20081123214438.GB2757@xxxxxxxxxxxxxxx> <20081123220446.GA8594@xxxxxxxxxxxx>
Simon Ruderich <simon@xxxxxxxxxxxx>:
> On Sun, Nov 23, 2008 at 10:44:39PM +0100, Frank Terbeck wrote:
> > Simon Ruderich <simon@xxxxxxxxxxxx>:
> >> I'm using Zsh 4.3.9 and trying to use vcs_info. I added the following to my
> >> .zshrc as documented in zshcontrib.
> >>
> >> autoload -Uz vcs_info
> >>
> >> zstyle ':vcs_info:*' actionformats \
> >> '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
> >> zstyle ':vcs_info:*' formats \
> >> '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
> >> zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
> >> precmd () { vcs_info }
> >> PS1='%F{5}[%F{2}%n%F{5}] %F{3}%3~ ${vcs_info_msg_0_}'"%f%# '
> > here is your unmatched double quote --^
>
> Thanks for your answer,
>
> but when I remove the double quote it still doesn't work and I get this error:
>
> unmatched '
>
> I took the example from the zshcontrib man page so it looks like there is an
> error.
Oops, yes. That's obviously wrong. Thanks for noticing.
That should be: PS1='%F{5}[%F{2}%n%F{5}] %F{3}%3~ ${vcs_info_msg_0_}%f%# '
> >> But if I use this vcs_info_msg_0_ is not expanded and stays in the prompt all
> >> the time.
> >
> > If you want to use $vcs_info_msg_0_ like this, you will need to use:
> > setopt promptsubst
> >
> > Regards, Frank
>
> Thanks, setting promptsubst worked fine.
>
> I followed the introduction in the zshcontrib man page. Would it be possible
> to add this information there so other users can set it up without any
> problems?
Absolutely. I thought I had mentioned it. Seems like I forgot.
Patch for both issues included below.
> Just curious, what other ways to use vcs_info than ${vcs_info_msg_0_} exist?
Well, a lot of people (me included) build their prompt in precmd().
That way you can always get the fresh value out of $vcs_info_msg_0_
without having to use prompt_subst. Here is how I am building my
prompt, if you're wondering what I'm talking about:
<http://ft.bewatermyfriend.org/comp/zsh/functions/prompt_ft_setup.html>
Regards, Frank
Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.92
diff -u -r1.92 contrib.yo
--- Doc/Zsh/contrib.yo 20 Nov 2008 18:12:32 -0000 1.92
+++ Doc/Zsh/contrib.yo 23 Nov 2008 22:25:11 -0000
@@ -362,12 +362,15 @@
'%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
precmd () { vcs_info }
-PS1='%F{5}[%F{2}%n%F{5}] %F{3}%3~ ${vcs_info_msg_0_}'"%f%# ')
+PS1='%F{5}[%F{2}%n%F{5}] %F{3}%3~ ${vcs_info_msg_0_}%f%# ')
Obviously, the last two lines are there for demonstration: You need to
call var(vcs_info) from your var(precmd) function. Once that is done you need
a tt(single quoted) var('${vcs_info_msg_0_}') in your prompt.
+To be able to use var('${vcs_info_msg_0_}') directly in your prompt like
+this, you will need to have the tt(PROMPT_SUBST) option enabled.
+
Now call the tt(vcs_info_printsys) utility from the command line:
example(% vcs_info_printsys
Messages sorted by:
Reverse Date,
Date,
Thread,
Author