Add zsh completion script (finally)

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan
2017-04-26 09:34:35 -07:00
parent a19b9535f6
commit 5933a7bbf8
2 changed files with 15 additions and 9 deletions

12
completion/kubectx.zsh Normal file
View File

@@ -0,0 +1,12 @@
#compdef kubectx
KUBECTX="${HOME}/.kube/kubectx"
PREV=""
if [ -f "$KUBECTX" ]; then
# show '-' only if there's a saved previous context
PREV=$(cat "${KUBECTX}")
_arguments "1: :((-\:Back\ to\ ${PREV} \
$(kubectl config get-contexts | awk '{print $2}' | tail -n +2)))"
else
_arguments "1: :($(kubectl config get-contexts | awk '{print $2}' | tail -n +2))"
fi