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
Merged

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

merged 1 commit into from
Oct 24, 2019

Conversation

hpedrorodrigues
Copy link
Contributor

  • Add basic zsh completion for subcommand -d.

Fixes #40

Comment on lines +12 to +13
"-d:*: :(${all_contexts})" \
"(- *): :(- ${all_contexts})"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (-).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok 😄

@ahmetb ahmetb merged commit 9645e5c into ahmetb:master Oct 24, 2019
@ahmetb
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 zsh-completion branch October 24, 2019 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubectx -d: add shell completion (zsh)
3 participants