From 6e0a1591e01fd22a063c2f900cac2af3f05100d8 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Mon, 15 Nov 2021 20:05:49 +0100 Subject: [PATCH] Added hability to switch to a context using a partial name --- kubectx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kubectx b/kubectx index 12ea40c..8718468 100755 --- a/kubectx +++ b/kubectx @@ -108,7 +108,11 @@ save_context() { } switch_context() { - $KUBECTL config use-context "${1}" + if [ "$(get_contexts | grep -c "${1}")" -eq 1 ]; then + $KUBECTL config use-context "$(get_contexts | grep "${1}")" + else + $KUBECTL config use-context "${1}" + fi } choose_context_interactive() {