From 4f710262666bfa21bbbcfac6cbafa7b552f1c640 Mon Sep 17 00:00:00 2001 From: Ken Kelly Date: Tue, 2 Jul 2024 11:12:42 -0400 Subject: [PATCH] fix(kubectx): fix kubectx_prompt_info for contexts without spaces. --- plugins/kubectx/kubectx.plugin.zsh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/kubectx/kubectx.plugin.zsh b/plugins/kubectx/kubectx.plugin.zsh index a3210facc..27de12e70 100644 --- a/plugins/kubectx/kubectx.plugin.zsh +++ b/plugins/kubectx/kubectx.plugin.zsh @@ -9,5 +9,14 @@ function kubectx_prompt_info() { # use value in associative array if it exists # otherwise fall back to the context name - echo "${kubectx_mapping[\"$current_ctx\"]:-${current_ctx:gs/%/%%}}" + + local mapped_ctx + + if [[ $current_ctx =~ " " ]]; then + mapped_ctx="${kubectx_mapping[\"$current_ctx\"]}" + else + mapped_ctx="${kubectx_mapping[$current_ctx]}" + fi + + echo "${mapped_ctx:-${current_ctx:gs/%/%%}}" }