mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-09-09 12:29:07 +00:00
This allows linking as "kctx" and "kns" to prevent overlap with kubectl Tab completion when user hits `ku<Tab>`. Fixes #3. Also fixed variables KUBECTX and PREV leaking to zsh shell once the _kubectx function is invoked. Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
13 lines
376 B
Bash
13 lines
376 B
Bash
#compdef kubectx kctx=kubectx
|
|
|
|
local KUBECTX="${HOME}/.kube/kubectx"
|
|
PREV=""
|
|
if [ -f "$KUBECTX" ]; then
|
|
# show '-' only if there's a saved previous context
|
|
local PREV=$(cat "${KUBECTX}")
|
|
_arguments "1: :((-\:Back\ to\ ${PREV} \
|
|
$(kubectl config get-contexts --output='name')))"
|
|
else
|
|
_arguments "1: :($(kubectl config get-contexts --output='name'))"
|
|
fi
|