aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorRoman Perepelitsa <roman.perepelitsa@gmail.com>2023-10-23 11:44:15 +0300
committerRoman Perepelitsa <roman.perepelitsa@gmail.com>2023-10-23 11:44:15 +0300
commit430616734aa06ff3def48cb511fb43db7466a64e (patch)
treebbebd365af58e383777bc88f36ca3a9d18e4eff8 /internal
parentc7fa7d6748cf6935ff7aeaa4d0d76a1ed2bfb852 (diff)
make terraform_version compatible with tfenv (#2049)
Diffstat (limited to 'internal')
-rw-r--r--internal/p10k.zsh14
1 files changed, 9 insertions, 5 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index dbc69c41..09985e0b 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -5021,12 +5021,16 @@ _p9k_prompt_terraform_init() {
}
function prompt_terraform_version() {
- _p9k_cached_cmd 0 '' terraform --version || return
- local v=${_p9k__ret#Terraform v}
- (( $#v < $#_p9k__ret )) || return
- v=${v%%$'\n'*}
+ local v cfg terraform=${commands[terraform]}
+ _p9k_upglob .terraform-version -. || cfg=$_p9k__parent_dirs[$?]/.terraform-version
+ if _p9k_cache_stat_get $0.$TFENV_TERRAFORM_VERSION $terraform $cfg; then
+ v=$_p9k__cache_val[1]
+ else
+ v=${${"$(terraform --version 2>/dev/null)"#Terraform v}%%$'\n'*} || v=
+ _p9k_cache_stat_set "$v"
+ fi
[[ -n $v ]] || return
- _p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' $v
+ _p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' ${v//\%/%%}
}
_p9k_prompt_terraform_version_init() {