From b96868bfc4e16efdf8ab88c7bae4aac116c3f81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 13 Jul 2024 19:18:54 +0200 Subject: [PATCH] Skip forks in `tofu_version_prompt_info` --- plugins/opentofu/opentofu.plugin.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/opentofu/opentofu.plugin.zsh b/plugins/opentofu/opentofu.plugin.zsh index 175da4dcf..c6844c84a 100644 --- a/plugins/opentofu/opentofu.plugin.zsh +++ b/plugins/opentofu/opentofu.plugin.zsh @@ -19,9 +19,11 @@ function tofu_prompt_info() { echo "${ZSH_THEME_TOFU_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TOFU_PROMPT_SUFFIX-]}" } +# tofu version prompt function function tofu_version_prompt_info() { - local tofu_version - tofu_version=$(tofu --version | head -n 1 | cut -d ' ' -f 2) + # get the output of `tofu --version` in a single line, and get the second word after splitting by a space + local tofu_version=${${(s: :)$(tofu --version)}[2]} + # make sure to escape % signs in the version string to prevent command injection echo "${ZSH_THEME_TOFU_VERSION_PROMPT_PREFIX-[}${tofu_version:gs/%/%%}${ZSH_THEME_TOFU_VERSION_PROMPT_SUFFIX-]}" }