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

Re: Composing completions for a wrapper script



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