mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-07-06 20:08:38 +00:00
Add zsh completion for kubectx subcommand (-d) (#178)
- 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
This commit is contained in:
parent
00a1e12bfb
commit
9645e5c62c
@ -2,11 +2,17 @@
|
|||||||
|
|
||||||
local KUBECTX="${HOME}/.kube/kubectx"
|
local KUBECTX="${HOME}/.kube/kubectx"
|
||||||
PREV=""
|
PREV=""
|
||||||
|
|
||||||
|
local all_contexts="$(kubectl config get-contexts --output='name')"
|
||||||
if [ -f "$KUBECTX" ]; then
|
if [ -f "$KUBECTX" ]; then
|
||||||
# show '-' only if there's a saved previous context
|
# show '-' only if there's a saved previous context
|
||||||
local PREV=$(cat "${KUBECTX}")
|
local PREV=$(cat "${KUBECTX}")
|
||||||
_arguments "1: :(-
|
|
||||||
$(kubectl config get-contexts --output='name'))"
|
_arguments \
|
||||||
|
"-d:*: :(${all_contexts})" \
|
||||||
|
"(- *): :(- ${all_contexts})"
|
||||||
else
|
else
|
||||||
_arguments "1: :($(kubectl config get-contexts --output='name'))"
|
_arguments \
|
||||||
|
"-d:*: :(${all_contexts})" \
|
||||||
|
"(- *): :(${all_contexts})"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user