-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
- 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
"-d:*: :(${all_contexts})" \ | ||
"(- *): :(- ${all_contexts})" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 (
-
).
There was a problem hiding this comment.
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”?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok 😄
This will be part of the new release since there's no urgent user demand. |
Fixes #40