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

Re: detect if compinit was run and rerun



Hi all,

thanks for your replies

I would like to avoid suggesting users to extend their fpath themselves:
the entire idea of that script we're deploying is there is exactly one
place to pick a version of the software stack, so users do not need to edit
their shell setup, log out&in to switch versions, which we want to enable
them to do after logging in. also our homedirs are shared over different
operating systems …

I appreciate the comment that my idea would hammer zcompdump, I'll try in
any case what the time penalty on our systems is.

Anyway the snippet by Sebastian looks good and seems to do the job.
(And I don't need to worry about users who might call `compinit -u`)

Thanks,
Paul



2018-06-01 19:46 GMT+02:00 Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>:

> On 1 June 2018 at 19:12, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> > regenerations of the cache instead of 0. Instead, you should not do
> > that. Just make sure your code that changes fpath is run before the
> > user runs compinit (by asking the user to configure their shell
>
> If this would be about startup of zsh, I would agree as second
> compinit call with $fpath changed adds 820 ms. But for some dynamic
> Zsh use with things plugged in and out, compinit should be a good
> choice, it is specifically adapted to detect changes (it checks number
> of _* files AFAIR?).
>
> > correctly). If you absolutely want to add a completer at runtime, it
> > is probably better to use only compdef+autoload and not compinit. I
> > don't see any reason why the user would want to avoid having these
> > completers always configured though.
>
> Good point, compinit interiors are quite easy to grasp and manual
> plugging is possible. For example, this code is generated by Zplugin's
> installer:
>
> autoload -Uz _zplugin
> (( ${+_comps} )) && _comps[zplugin]=_zplugin
>
> This plugs zplugin completion into already initialized completion
> system. I'm doing this because until user organizes his .zshrc, some
> time typically passes, and with above, during this time zplugin will
> have a working completion. The ${+_comps} check detects if completion
> is already initialized.
>
> --
> Best regards,
> Sebastian Gniazdowski
>


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