d12c2ea4e83779250fda8096571682d9d340ee09

Author
Maciej Lasyk <maciek@lasyk.info>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Plugins: Terraform (#6373)

Expanded Terraform plugin with function that can be used to show workspace name in the zsh prompt

Diff

 1diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md
 2index 44e38a1c0b2761bbbad77bf4aa3a28ee0e9b0be6..b39f9916b8f4c02ddb1f415128383224941f878e 100644
 3--- a/plugins/terraform/README.md
 4+++ b/plugins/terraform/README.md
 5@@ -9,3 +9,13 @@ Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely a
 6 ### Usage
 7 
 8  * Type `terraform` into your prompt and hit `TAB` to see available completion options
 9+
10+### Expanding ZSH prompt with current Terraform workspace name
11+
12+If you want to get current Terraform workspace name in your ZSH prompt open 
13+your .zsh-theme file and in a choosen place insert:
14+
15+```
16+$FG[045]\
17+$(terraform_prompt_info)\
18+```
19diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh
20new file mode 100644
21index 0000000000000000000000000000000000000000..84eec5cc1ade74ddeb445d74212fdf16ad0b4d24
22--- /dev/null
23+++ b/plugins/terraform/terraform.plugin.zsh
24@@ -0,0 +1,7 @@
25+function terraform_prompt_info() {
26+    # check if in terraform dir
27+    if [ -d .terraform ]; then
28+      workspace=$(terraform workspace show 2> /dev/null) || return
29+      echo "[${workspace}]"
30+    fi
31+}