From 0ab87c26c17171ae6162ff379a0c704fa57dff2e Mon Sep 17 00:00:00 2001 From: Vlad Korolev Date: Mon, 8 Mar 2021 01:46:42 -0800 Subject: [PATCH] fix(terraform): use faster method to get workspace (#9709) Also add tf_prompt_info to the list of prompt functions so theme writers are aware of it --- lib/prompt_info_functions.zsh | 1 + plugins/terraform/terraform.plugin.zsh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh index 5069c4b21..48f033da6 100644 --- a/lib/prompt_info_functions.zsh +++ b/lib/prompt_info_functions.zsh @@ -18,6 +18,7 @@ function chruby_prompt_info \ vi_mode_prompt_info \ virtualenv_prompt_info \ jenv_prompt_info \ + tf_prompt_info \ { return 1 } diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh index 2c42d394d..997241c9a 100644 --- a/plugins/terraform/terraform.plugin.zsh +++ b/plugins/terraform/terraform.plugin.zsh @@ -2,8 +2,8 @@ function tf_prompt_info() { # dont show 'default' workspace in home dir [[ "$PWD" == ~ ]] && return # check if in terraform dir - if [ -d .terraform ]; then - workspace=$(terraform workspace show 2> /dev/null) || return + if [[ -d .terraform && -r .terraform/environment ]]; then + workspace=$(cat .terraform/environment) || return echo "[${workspace}]" fi }