Diff
1diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md
2index c19f2ad1cd15e3364e0ed989b0710fe1bfa77e5e..fc9a9f005c0403788a97cb65d90c41e5b343034f 100644
3--- a/plugins/terraform/README.md
4+++ b/plugins/terraform/README.md
5@@ -1,7 +1,7 @@
6 # Terraform plugin
7
8-Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
9-It adds completion for `terraform`, as well as aliases and a prompt function.
10+Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently. It adds
11+completion for `terraform`, as well as aliases and a prompt function.
12
13 To use it, add `terraform` to the plugins array of your `~/.zshrc` file:
14
15@@ -11,7 +11,7 @@ plugins=(... terraform)
16
17 ## Requirements
18
19-* [Terraform](https://terraform.io/)
20+- [Terraform](https://terraform.io/)
21
22 ## Aliases
23
24@@ -29,11 +29,12 @@ plugins=(... terraform)
25
26 ## Prompt function
27
28-You can add the current Terraform workspace in your prompt by adding `$(tf_prompt_info)`
29-to your `PROMPT` or `RPROMPT` variable.
30+You can add the current Terraform workspace in your prompt by adding `$(tf_prompt_info)`,
31+`$(tf_version_prompt_info)` to your `PROMPT` or `RPROMPT` variable.
32
33 ```sh
34 RPROMPT='$(tf_prompt_info)'
35+RPROMPT='$(tf_version_prompt_info)'
36 ```
37
38 You can also specify the PREFIX and SUFFIX for the workspace with the following variables:
39@@ -41,4 +42,6 @@ You can also specify the PREFIX and SUFFIX for the workspace with the following
40 ```sh
41 ZSH_THEME_TF_PROMPT_PREFIX="%{$fg[white]%}"
42 ZSH_THEME_TF_PROMPT_SUFFIX="%{$reset_color%}"
43+ZSH_THEME_TF_VERSION_PROMPT_PREFIX="%{$fg[white]%}"
44+ZSH_THEME_TF_VERSION_PROMPT_SUFFIX="%{$reset_color%}"
45 ```
46diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh
47index 7006f204bff3cf6d4a1f6b123c24659516651e54..ccca5468484d4afd37b1ed74fc6eeb052065f090 100644
48--- a/plugins/terraform/terraform.plugin.zsh
49+++ b/plugins/terraform/terraform.plugin.zsh
50@@ -8,6 +8,13 @@ function tf_prompt_info() {
51 echo "${ZSH_THEME_TF_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}"
52 }
53
54+function tf_version_prompt_info() {
55+ local terraform_version
56+ terraform_version=$(terraform --version | head -n 1 | cut -d ' ' -f 2)
57+ echo "${ZSH_THEME_TF_VERSION_PROMPT_PREFIX-[}${terraform_version:gs/%/%%}${ZSH_THEME_TF_VERSION_PROMPT_SUFFIX-]}"
58+}
59+
60+
61 alias tf='terraform'
62 alias tfa='terraform apply'
63 alias tfc='terraform console'