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

Re: Git info in right prompt



John Magolske <listmail@xxxxxxx>:
> * Dirk-Jan C. Binnema <djcb.bulk@xxxxxxxxx> [100102 15:52]:
> > >>>>> "John" == John Magolske <listmail@xxxxxxx> writes:
> > John> I'd like to display the current git branch in the right prompt,
> > John> ...
> > John> ... and I can't seem to make any "display git branch" thing work
> > 
> > Below is my setup for my prompts; it's a bit *more* than what you ask
> > for, but it is hopefully helpful.
> 
> Thanks, 'tis more than what I need at the moment, but it'll be handy
> to refer to over time for sure. Here's what I've settled on for now:
> 
>   autoload -Uz vcs_info
>   precmd () {
>       psvar=()
>       vcs_info
>       [[ -n $vcs_info_msg_0_ ]] && psvar[1]="$vcs_info_msg_0_"
>   }
>   
>   export PROMPT="%B%F{green} %~%(1v.%b%F{yellow}%1v%f.) %B%F{yellow}%# %b%F{white}"

Don't export $PROMPT. Child processes do not need to know about it and
it causes more harm than it does good.

> However, for some reason the git info will appear in my prompt only
> if I do something like `mv /etc/zsh/zshrc /etc/zsh/zshrc-1`
> Seems something in the zshrc that came with the Grml distro I'm
> using is preventing the display of git info (or maybe I'm just doing
> something wrong). I tried reading through and commenting out various
> sections of that zshrc to figure out what might be causing this
> interaction to no avail. Any ideas?

Well, grml's zshrc does a lot of stuff already. And it uses vcs_info,
too. It also has a precmd() function of its own.

There is potentially more than one way to achieve what you want.

The easiest is probably to change the precmd() function and the PS1=
definition in grml's zsh setup to your liking. That would make
upgrading later a little hairier, though. You could also overwrite
precmd() and PS1= in your user specific file. But note, that grml's
precmd() may already do things you want to keep so copy code for that
stuff over into your file.

If your questions are really about grml's *specific* setup, then
there's a user mailing list for the project and an IRC channel named
#grml on freenode. Those places may be more suited.

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



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