Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zsh completion for kubectx subcommand (-d) #178

Merged
merged 1 commit into from Oct 24, 2019

Conversation

@hpedrorodrigues
Copy link
Contributor

hpedrorodrigues commented Oct 24, 2019

  • Add basic zsh completion for subcommand -d.

Fixes #40

- Add basic completion for subcommand -d.
  Note: Kubectx will suggest all available contexts.

- References:
  - http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System
  - https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org
@googlebot googlebot added the cla: yes label Oct 24, 2019
"-d:*: :(${all_contexts})" \
"(- *): :(- ${all_contexts})"
Comment on lines +12 to +13

This comment has been minimized.

Copy link
@ahmetb

ahmetb Oct 24, 2019

Owner

thanks a lot for this PR!
Can you explain this syntax and how it works real quick for me?

This comment has been minimized.

Copy link
@hpedrorodrigues

hpedrorodrigues Oct 24, 2019

Author Contributor

Hi, of course.

"-d:*: :(${all_contexts})"

  • -d -> The kubectx subcommand.
  • '*' -> This describes multiple arguments. All contexts matching the pattern (*, all) will be completed.
  • ' ' -> An empty description.
  • (${all_contexts}) -> An action describing all words to be completed.

"(- *): :(- ${all_contexts})"

  • (- *) -> If one of the contexts has already been selected (and is on the command line), it will not complete other options anymore. (i.e this will avoid kubectx ctx1 ctx2)
  • ' ' -> An empty description.
  • (- ${all_contexts}) -> An action describing all words to be completed, including the current one (-).

This comment has been minimized.

Copy link
@ahmetb

ahmetb Oct 24, 2019

Owner

Why does the description have a space character to be “empty”?

This comment has been minimized.

Copy link
@hpedrorodrigues

hpedrorodrigues Oct 24, 2019

Author Contributor

AFAIK the spec needs this space to know what optspec I'm using (optname:*pattern:message:action and no optname:message:action). I can add a description for them if you want. WDYT?

This comment has been minimized.

Copy link
@hpedrorodrigues

hpedrorodrigues Oct 24, 2019

Author Contributor

Another relevant point is I'm not completing with all the current subcommands like -d, -h and -c. The subcommand -d will only be completed if the user enters the -d option (typing).

This comment has been minimized.

Copy link
@ahmetb

ahmetb Oct 24, 2019

Owner

Yeah, makes sense. Thanks.
I might find you again when there's an issue with this file. 😄

This comment has been minimized.

Copy link
@hpedrorodrigues

hpedrorodrigues Oct 24, 2019

Author Contributor

Ok 😄

@ahmetb ahmetb merged commit 9645e5c into ahmetb:master Oct 24, 2019
2 checks passed
2 checks passed
cla/google All necessary CLAs are signed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ahmetb

This comment has been minimized.

Copy link
Owner

ahmetb commented Oct 24, 2019

This will be part of the new release since there's no urgent user demand.

@hpedrorodrigues hpedrorodrigues deleted the hpedrorodrigues:zsh-completion branch Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.