zsh-users
 help / color / mirror / code / Atom feed
* vcs_info problem
@ 2008-11-23 21:32 Simon Ruderich
  2008-11-23 21:44 ` Frank Terbeck
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Ruderich @ 2008-11-23 21:32 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]

Hi,

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%# '

But it gives me the this error.

    /.zshrc:358: unmatched "

So I tried a simpler approach:

    autoload -Uz vcs_info

    precmd () { vcs_info }
    PS1='${vcs_info_msg_0_}'

But if I use this vcs_info_msg_0_ is not expanded and stays in the prompt all
the time.

    ${vcs_info_msg_0_}

If I execute vcs_info_lastmsg it gives me the correct result when I'm in or
outside of a repository.

Thanks for your help,
Simon
-- 
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x6115F804EFB33229

[-- Attachment #2: Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: vcs_info problem
  2008-11-23 21:32 vcs_info problem Simon Ruderich
@ 2008-11-23 21:44 ` Frank Terbeck
  2008-11-23 22:04   ` Simon Ruderich
  0 siblings, 1 reply; 6+ messages in thread
From: Frank Terbeck @ 2008-11-23 21:44 UTC (permalink / raw)
  To: zsh-users

Simon Ruderich <simon@ruderich.org>:
> 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 --^

> But it gives me the this error.
> 
>     /.zshrc:358: unmatched "
> 
> So I tried a simpler approach:
> 
>     autoload -Uz vcs_info
> 
>     precmd () { vcs_info }
>     PS1='${vcs_info_msg_0_}'
> 
> 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

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: vcs_info problem
  2008-11-23 21:44 ` Frank Terbeck
@ 2008-11-23 22:04   ` Simon Ruderich
  2008-11-23 22:26     ` Frank Terbeck
  2008-11-26  2:58     ` Clint Adams
  0 siblings, 2 replies; 6+ messages in thread
From: Simon Ruderich @ 2008-11-23 22:04 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1552 bytes --]

On Sun, Nov 23, 2008 at 10:44:39PM +0100, Frank Terbeck wrote:
> Simon Ruderich <simon@ruderich.org>:
>> 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.

>> 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?

Just curious, what other ways to use vcs_info than ${vcs_info_msg_0_} exist?

Thanks,
Simon
-- 
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x6115F804EFB33229

[-- Attachment #2: Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: vcs_info problem
  2008-11-23 22:04   ` Simon Ruderich
@ 2008-11-23 22:26     ` Frank Terbeck
  2008-11-23 23:18       ` Simon Ruderich
  2008-11-26  2:58     ` Clint Adams
  1 sibling, 1 reply; 6+ messages in thread
From: Frank Terbeck @ 2008-11-23 22:26 UTC (permalink / raw)
  To: zsh-users

Simon Ruderich <simon@ruderich.org>:
> On Sun, Nov 23, 2008 at 10:44:39PM +0100, Frank Terbeck wrote:
> > Simon Ruderich <simon@ruderich.org>:
> >> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: vcs_info problem
  2008-11-23 22:26     ` Frank Terbeck
@ 2008-11-23 23:18       ` Simon Ruderich
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Ruderich @ 2008-11-23 23:18 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1200 bytes --]

On Sun, Nov 23, 2008 at 11:26:58PM +0100, Frank Terbeck wrote:
>> [snip]
> 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%# '
>
>>> [snip]
>> 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.

Thanks for your quick help. Works perfectly.

>> 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

Thanks, this sounds very interesting.

Simon
-- 
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x6115F804EFB33229

[-- Attachment #2: Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: vcs_info problem
  2008-11-23 22:04   ` Simon Ruderich
  2008-11-23 22:26     ` Frank Terbeck
@ 2008-11-26  2:58     ` Clint Adams
  1 sibling, 0 replies; 6+ messages in thread
From: Clint Adams @ 2008-11-26  2:58 UTC (permalink / raw)
  To: Simon Ruderich; +Cc: zsh-users

On Sun, Nov 23, 2008 at 11:04:46PM +0100, Simon Ruderich wrote:
> Just curious, what other ways to use vcs_info than ${vcs_info_msg_0_} exist?

vcs_info
psvar=( ${vcs_info_msg_0_} )
PS1='%F{5}[%F{2}%n%F{5}] %F{3}%3~ %v%f%# '


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-11-26  2:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-23 21:32 vcs_info problem Simon Ruderich
2008-11-23 21:44 ` Frank Terbeck
2008-11-23 22:04   ` Simon Ruderich
2008-11-23 22:26     ` Frank Terbeck
2008-11-23 23:18       ` Simon Ruderich
2008-11-26  2:58     ` Clint Adams

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).