Zsh Mailing List Archive
Messages sorted by:
Re: Use of vcs_info
- X-seq: zsh-users 14952
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Use of vcs_info
- Date: Mon, 22 Mar 2010 04:48:34 -0400 (EDT)
- In-reply-to: <87y6hk3grn.fsf@xxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <alpine.LNX.2.01.1003212254040.19615@xxxxxxxxxxx> <87y6hk3grn.fsf@xxxxxxxxxxxxxxxxxxxxxx>
On Mon, 22 Mar 2010, Frank Terbeck wrote:
> Benjamin R. Haskell wrote:
> > I don't fully understand how best to use vcs_info.
> First just to make sure: you did find the documentation in
> zshcontrib(1), right? (man zshcontrib | less -p GATHER)
I could've sworn I'd looked in zshall. Apparently not. Guess I'd only
googled it. (Thanks also to Mikael.)
> > My first question is: what's with the weird $vcs_info_msg_#_
> > variable names? (Why not an array?)
> Those variables are exported (there was a reason for it, I don't
> remember what it was exactly). And you can't export arrays.
Ah, okay. So... why the trailing underscore? Not a huge deal, just
> > But, beyond that, my big question is: Is there a way to access the
> > vcs_comm variable that's sprinkled throughout the VCS_Info functions
> You shouldn't.
> That's an associative array to allow bidirectional communication
> between various parts of vcs_info. If you want to know some internals,
> I could explain them, but for *using* vcs_info, you do not need to
> know anything about that particular variable.
Ah. I misinterpreted the '_comm' as 'common', not 'communication'. I
hadn't really delved too deeply yet, but it looked like that var was
updated in a few places that were grabbing items I wanted to examine.
> > directory? My guess is that the easiest thing for me to do would be
> > to simply remove the 'local -Ax vcs_comm' line in vcs_info, but
> > everything else is so well-organized that I figured I must just be
> > missing some way to get that variable exported.
> What do you need that variable for? Maybe if you'd explain what you want
> to do, I'd have a suggestion.
> > The most helpful page so far was Frank Terbeck's prompt_ft_setup
> > page. Otherwise I'd've had to have read even more of the code to
> > figure out the various
> > zstyle ':vcs_info:*' actionformats ''
> > zstyle ':vcs_info:*' formats ''
> > zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat
> > tricks that are available.
> > I already do a bunch of stuff in my pre_cmd and pre_exec functions, and
> > I'd really like to just add some things to my prompt conditioned on
> > whether (for example) the current git repo is in a rebase, and maybe a
> > shortened version of the branch name. So, is there a way to get the
> > info out of vcs_info?
> Yes, there is.
> The "shortened" make it a little trickier, though. In currently
> released code (4.3.7), you can make one format to just be "%b" and
> change the corresponding variable after calling vcs_info your precmd
> Vcs_info in CVS has hooks. The manual explains them in some detail and
> gives some simpler examples. You can use a "set-message" hook to get
> full control over what will be inserted for the branch-name. That is
> probably what you want.
Thanks for the pointers. I saw the hook stuff in the git repo, but I
think I'm going to do something like your format suggestion: just make
the various formats easily-splitable, and parse out what I want.
The two things I want are abbreviated git branch names (not sure what
I'll decide on how to abbreviate), and to modify my entire prompt when
in a git rebase (as a big visual reminder to myself).
Both of those would be easy-peasy if I had some kind of data structure
storing the parsed VCS data (rather than a formatted string), hence the
Messages sorted by: