From d12c2ea4e83779250fda8096571682d9d340ee09 Mon Sep 17 00:00:00 2001 From: Maciej Lasyk Date: Tue, 7 Nov 2017 16:45:25 +0100 Subject: [PATCH] Plugins: Terraform (#6373) Expanded Terraform plugin with function that can be used to show workspace name in the zsh prompt --- plugins/terraform/README.md | 10 ++++++++++ plugins/terraform/terraform.plugin.zsh | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 plugins/terraform/terraform.plugin.zsh diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md index 44e38a1c..b39f9916 100644 --- a/plugins/terraform/README.md +++ b/plugins/terraform/README.md @@ -9,3 +9,13 @@ Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely a ### Usage * Type `terraform` into your prompt and hit `TAB` to see available completion options + +### Expanding ZSH prompt with current Terraform workspace name + +If you want to get current Terraform workspace name in your ZSH prompt open +your .zsh-theme file and in a choosen place insert: + +``` +$FG[045]\ +$(terraform_prompt_info)\ +``` diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh new file mode 100644 index 00000000..84eec5cc --- /dev/null +++ b/plugins/terraform/terraform.plugin.zsh @@ -0,0 +1,7 @@ +function terraform_prompt_info() { + # check if in terraform dir + if [ -d .terraform ]; then + workspace=$(terraform workspace show 2> /dev/null) || return + echo "[${workspace}]" + fi +}