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

Re: detect if command has a completion function



>     how can I detect if a given command has a completion function, from within another function?
> I want to loop over many commands quickly, so I want to avoid resorting to searching directories with find if possible.
>
> The reason I need this capability is to help with a function I've written for cleaning up .zshrc files.
> I tend to collect lots of "compdef _gnu_generic cmd1 cmd2..." lines in my .zshrc, but many of the commands flagged for completion with _gnu_generic are not present on other systems where I install the same .zshrc.

You can use the `$_comps` array which controls which completion
function is assigned to a command.
For example, the completion function for `ls` is `_ls`:

  $ echo $_comps[ls]
  _ls

And so on

Marc




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