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

Re: detect if command has a completion function



On Sat, Aug 29, 2020 at 11:33 AM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
>  Don't bother removing the compdef lines, just remove their results.

This could be taken a step further:

all_comps=( ${(v)_comps} )
completed=( ${(k)_comps:#-*} )
installed=( ${(k)builtins} ${(k)functions} ${(k)commands} )
not_installed=( ${completed:|installed} )
unset '_comps['${^not_installed}']'
used_comps=( ${(v)_comps} )
unused_comps=( ${all_comps:|used_comps} )
unfunction ${(k)functions:*unused_comps}

(Note the tweak to completed=(...), I think -* covers what needs ignoring.)




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