mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-06-22 13:41:11 +00:00
- 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
19 lines
447 B
Bash
19 lines
447 B
Bash
#compdef kubectx kctx=kubectx
|
|
|
|
local KUBECTX="${HOME}/.kube/kubectx"
|
|
PREV=""
|
|
|
|
local all_contexts="$(kubectl config get-contexts --output='name')"
|
|
if [ -f "$KUBECTX" ]; then
|
|
# show '-' only if there's a saved previous context
|
|
local PREV=$(cat "${KUBECTX}")
|
|
|
|
_arguments \
|
|
"-d:*: :(${all_contexts})" \
|
|
"(- *): :(- ${all_contexts})"
|
|
else
|
|
_arguments \
|
|
"-d:*: :(${all_contexts})" \
|
|
"(- *): :(${all_contexts})"
|
|
fi
|