Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Composing completions for a wrapper script
- X-seq: zsh-users 27305
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Cc: Anton Suslov <anton_suslov@xxxxxx>
- Subject: Re: Composing completions for a wrapper script
- Date: Sun, 31 Oct 2021 13:32:33 -0700
- Archived-at: <https://zsh.org/users/27305>
- In-reply-to: <CAHYJk3QPpM8kRwxY=LTtcWQcj_jxMnX7Mr0EB1+3VxBj8jN4zQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <C4958944-8A7C-4345-8C19-BC08BBE120AB@me.com> <CAHYJk3QPpM8kRwxY=LTtcWQcj_jxMnX7Mr0EB1+3VxBj8jN4zQ@mail.gmail.com>
On Sun, Oct 31, 2021 at 6:23 AM Mikael Magnusson <mikachu@xxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author