From: "Marc Cornellà" <marc.cornella@live.com>
To: vapnik spaknik <vapniks@yahoo.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: detect if command has a completion function
Date: Sat, 29 Aug 2020 19:21:06 +0200 [thread overview]
Message-ID: <AM6PR02MB5638F3E9C716E62DD6691A3584530@AM6PR02MB5638.eurprd02.prod.outlook.com> (raw)
In-Reply-To: <301108111.164161.1598719628682@mail.yahoo.com>
> 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
next prev parent reply other threads:[~2020-08-29 17:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <301108111.164161.1598719628682.ref@mail.yahoo.com>
2020-08-29 16:47 ` vapnik spaknik
2020-08-29 17:21 ` Marc Cornellà [this message]
[not found] ` <AM6PR02MB56389D8F9832FA6C58D8EF6E84530@AM6PR02MB5638.eurprd02.prod.outlook.com>
2020-08-29 17:38 ` vapnik spaknik
2020-08-29 18:33 ` Bart Schaefer
2020-08-29 19:27 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM6PR02MB5638F3E9C716E62DD6691A3584530@AM6PR02MB5638.eurprd02.prod.outlook.com \
--to=marc.cornella@live.com \
--cc=vapniks@yahoo.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).