From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Cc: Anton Suslov <anton_suslov@me.com>
Subject: Re: Composing completions for a wrapper script
Date: Sun, 31 Oct 2021 13:32:33 -0700 [thread overview]
Message-ID: <CAH+w=7a==7C5KBz=rwUkaPVkZHgZjhwaPUstaA9uzFrTHV3+7w@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3QPpM8kRwxY=LTtcWQcj_jxMnX7Mr0EB1+3VxBj8jN4zQ@mail.gmail.com>
On Sun, Oct 31, 2021 at 6:23 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> compdef -e 'shift words; (( CURRENT-- )); service=kubectl;
> words[1]=kubectl; _normal' kubectldc
>
> There is a side effect that if you try to complete the first word, it
> will try to complete command names. You can handle that with some
> extra code if you want, but at that point you should probably create a
> _kubectldc completer as it will become a bit unwieldy for a one-liner.
It's not too bad, assuming the first argument just needs ordinary
default completions.
compdef -e '((CURRENT>2)) && {
words[1,2]=(kubectl); (( CURRENT-- )); service=kubectl;
} || words[1]=:; _normal' kubectldc
If there is already a completion function for the DC argument, you can
replace "words[1]=:" with an assignment to service to select that
completion.
next prev parent reply other threads:[~2021-10-31 20:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-30 22:07 Anton Suslov
2021-10-30 23:00 ` Jérémie Roquet
2021-10-31 6:14 ` Anton Suslov
2021-10-31 13:22 ` Mikael Magnusson
2021-10-31 20:32 ` Bart Schaefer [this message]
2021-11-01 7:13 ` Anton Suslov
2021-11-01 7:53 ` Anton Suslov
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='CAH+w=7a==7C5KBz=rwUkaPVkZHgZjhwaPUstaA9uzFrTHV3+7w@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=anton_suslov@me.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).