Skip forks in tofu_version_prompt_info

This commit is contained in:
Marc Cornellà 2024-07-13 19:18:54 +02:00
commit b96868bfc4
No known key found for this signature in database
GPG key ID: 0314585E776A9C1B

View file

@ -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-]}"
}