From d87ab251c7fe18626b2d0c4e4a184e7bed7c508b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 3 Jan 2022 14:03:36 +0100 Subject: [PATCH] fix(kubectx): quote % in `kubectx_prompt_info` --- plugins/kubectx/kubectx.plugin.zsh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/kubectx/kubectx.plugin.zsh b/plugins/kubectx/kubectx.plugin.zsh index abbdc254b..af9a17ef1 100644 --- a/plugins/kubectx/kubectx.plugin.zsh +++ b/plugins/kubectx/kubectx.plugin.zsh @@ -1,9 +1,11 @@ typeset -A kubectx_mapping function kubectx_prompt_info() { - if [ $commands[kubectl] ]; then - local current_ctx=`kubectl config current-context` - # use value in associative array if it exists, otherwise fall back to the context name - echo "${kubectx_mapping[$current_ctx]:-$current_ctx}" - fi + (( $+commands[kubectl] )) || return + + local current_ctx=$(kubectl config current-context) + + # use value in associative array if it exists + # otherwise fall back to the context name + echo "${${kubectx_mapping[$current_ctx]:-$current_ctx}:gs/%/%%}" }