浏览代码

feat(terraform): support `TF_DATA_DIR` in `tf_prompt_info` (#12949)

soemiran 2 月之前
父节点
当前提交
1c34b0e67d
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      plugins/terraform/terraform.plugin.zsh

+ 2 - 2
plugins/terraform/terraform.plugin.zsh

@@ -2,9 +2,9 @@ function tf_prompt_info() {
   # dont show 'default' workspace in home dir
   # dont show 'default' workspace in home dir
   [[ "$PWD" != ~ ]] || return
   [[ "$PWD" != ~ ]] || return
   # check if in terraform dir and file exists
   # check if in terraform dir and file exists
-  [[ -d .terraform && -r .terraform/environment ]] || return
+  [[ -d "${TF_DATA_DIR:-.terraform}" && -r "${TF_DATA_DIR:-.terraform}/environment" ]] || return
 
 
-  local workspace="$(< .terraform/environment)"
+  local workspace="$(< "${TF_DATA_DIR:-.terraform}/environment")"
   echo "${ZSH_THEME_TF_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}"
   echo "${ZSH_THEME_TF_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}"
 }
 }