fix(kubectx): fix kubectx_prompt_info for contexts without spaces.

This commit is contained in:
Ken Kelly 2024-07-02 11:12:42 -04:00
commit 4f71026266

View file

@ -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/%/%%}}"
}