[clug] [OT] ZSH vcs_info help?

Alex Satrapa grail at goldweb.com.au
Wed May 4 19:19:28 MDT 2011


Apologies, this is somewhat off-topic for the CLUG list. I figured I'd try here first since I know some of you know ZSH far better than I do.

I'm trying to set up git/hg information in my ZSH prompt:

  10:59 .zsh.d ➤                    ±master!

Here you see the time, the name of the current directory (the path is summarised in the window title), then over on the right hand side the ± means it's a git repository (there would be a ☿ if it was Mercurial), the current branch name and a '!' to indicate that the repository is dirty.

I'm doing this using my customised version of Oh My ZSH: https://github.com/AlexSatrapa/oh-my-zsh - check the "alex" theme.

While trying to get it pulled back into the master Oh My ZSH, it was suggested that the VCS stuff be done using vcs_info, which is a common contrib shipped with ZSH. To this end I have tried the following commands in order to emulate my current RPROMPT information:

11:07 .oh-my-zsh ➤ autoload vcs_info                                             ±master!
11:07 .oh-my-zsh ➤ zstyle ':vcs_info:*:*:*' use-prompt-escapes true              ±master!
11:07 .oh-my-zsh ➤ zstyle ':vcs_info:*:*:*' check-for-changes true               ±master!
11:07 .oh-my-zsh ➤ vcs_info ; echo $vcs_info_msg_0_                              ±master!
 (git)-[master]-
11:08 .oh-my-zsh ➤ zstyle ':vcs_info:*' formats '%b%u%c'                         ±master!
[m.oh-my-zsh'%                                                                            
11:09 .oh-my-zsh ➤ vcs_info ; echo $vcs_info_msg_0_                              ±master!
master%u%c

I am expecting that setting 'use-prompt-escapes' to true will cause the %u and %c escapes to be replaced with 'U' and 'S' if the current repository has unstaged or staged changes (as per the ZSH manual).

Does anyone have a suggestion as to what I'm doing wrong?  As the adage goes, "when reality doesn't meet your expectations, it's not reality that has to change."  What am I missing, which is stopping ZSH vcs_info from behaving the way I'm expecting it to?

Alex
PS: my reference documentation is only §26.4 of the ZSH manual, "Gathering information from version control systems", and a bunch of scripts provided by other people such as https://github.com/blueyed/oh-my-zsh/blob/master/themes/blueyed.zsh-theme



More information about the linux mailing list