Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: detect if command has a completion function
- X-seq: zsh-users 26047
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: vapnik spaknik <vapniks@xxxxxxxxx>
- Subject: Re: detect if command has a completion function
- Date: Sat, 29 Aug 2020 11:33:19 -0700
- Archived-at: <https://zsh.org/users/26047>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2020-08/CAH%2Bw%3D7Z1XwGeqmOV0ZRnkwPepisyCwUxqf-zWLRq3x_ojnw%2BsQ%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-ot1-f54.google.com) smtp.remote-ip=209.85.210.54; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=skipped; arc=none
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S0eO3XGxQJ527rjvLom3KBVVAAjslsOz0IDKwsAMSgg=; b=KdO91D/2c8+qE2h2ychSyDyZ8feUORt7PY/Vw0BRKuq+CnOVfLgtTS9zb2/Pjzu+Gr vReON7INfupP8iA99AZykpJxg9FsyjzonQeYx7xnlzmoC5kLD32JtNREGI09yJPt+owW TUP9YrLk9F8Hb5fghTanc1dgRiAXZQBfxXCuYIIeADyIqS0rcWhvPT9sXmFs/FSeJqB4 k4OO6bnXXb1r3njdFf4CsZgOThnU+GAAvS/OBEItqXYJx1kya3A/L75p2cn6HehxSVV8 ZyEnOvNrcG/aiFF6+GU5h51jhXcY78QMPU1d+Uz9gypgjEf5KaY5D22EmwfYW1ZDFGWe 4RSA==
- In-reply-to: <301108111.164161.1598719628682@mail.yahoo.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-users>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-users.zsh.org>
- List-owner: <mailto:zsh-users-request@zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-users>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-users>
- References: <301108111.164161.1598719628682.ref@mail.yahoo.com> <301108111.164161.1598719628682@mail.yahoo.com>
- Sender: zsh-users-request@xxxxxxx
On Sat, Aug 29, 2020 at 9:47 AM vapnik spaknik <vapniks@xxxxxxxxx> wrote:
>
> The reason I need this capability is to help with a function I've written for cleaning up .zshrc files.
> ... I wrote a function which checks the commands mentioned in those "compdef _gnu_generic" lines, and removes any that are not present on the system:
Don't bother removing the compdef lines, just remove their results.
That way you won't have to add things back again if you install one of
those missing programs.
completed=( ${(k)_comps:#([^[:alnum:]]*)} )
installed=( ${(k)builtins} ${(k)functions} ${(k)commands} )
not_installed=( ${completed:|installed} )
unset '_comps['${^not_installed}']'
Just be sure you have done all your zmodloads and autoloads before
executing the above, or you'll remove completions for some builtins
and functions.
Older zsh will not have the ${name:|arrayname} syntax so you might
have to resort to
not_installed=( ${completed:#${~:-(${(j:|:)${(q)installed}})}} )
Messages sorted by:
Reverse Date,
Date,
Thread,
Author