From 0141d66224cb7a85b6072fe3e9c80df3f8d50285 Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Mon, 2 Apr 2018 23:52:18 -0700 Subject: [PATCH] Support "kubectx NAME=." to rename current-context Fixes #24. Signed-off-by: Ahmet Alp Balkan --- kubectx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kubectx b/kubectx index 4348b2ba..bf33a25d 100755 --- a/kubectx +++ b/kubectx @@ -30,6 +30,7 @@ USAGE: kubectx : switch to context kubectx - : switch to the previous context kubectx = : rename context to + kubectx =. : rename current-context to kubectx -h,--help : show this message EOF exit 1 @@ -122,6 +123,10 @@ rename_context() { local old_name="${1}" local new_name="${2}" + if [[ "${old_name}" == "." ]]; then + old_name="$(current_context)" + fi + # TODO(ahmetb) old_user and old_cluster are no longer used, clean up local old_user old_cluster old_user="$(user_of_context "${old_name}")"