Skip to content

Instantly share code, notes, and snippets.

@vainikkaj
Last active January 18, 2019 06:35
Show Gist options
  • Save vainikkaj/c2656abb3f54b58d293b3d7ed6ce9b74 to your computer and use it in GitHub Desktop.
Save vainikkaj/c2656abb3f54b58d293b3d7ed6ce9b74 to your computer and use it in GitHub Desktop.
kubectx zsh completion
#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: :(-
$(kubectl config get-contexts --output='name'))"
else
_arguments "1: :($(kubectl config get-contexts --output='name'))"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment