Improve formatting of Terraform plugin output

Improves the formatting of the Terraform plugin's `tf_prompt_info()`
function (see #6373 and #6418). It:
- adds a `tf:` prefix to indicate that what follows is the Terraform
  workspace
- adds colorization and formatting to make the appearance more similar
  to the `git-prompt` plugin
- adds a trailing space to separate the prompt from user input
This commit is contained in:
Chris Belyea 2017-11-17 09:27:15 -05:00
parent e273cf004e
commit 288e596566
No known key found for this signature in database
GPG Key ID: 5D30516E38E2FDD0

View File

@ -1,7 +1,10 @@
function tf_prompt_info() { function tf_prompt_info() {
RESET="%{${reset_color}%}"
# check if in terraform dir # check if in terraform dir
if [ -d .terraform ]; then if [ -d .terraform ]; then
workspace=$(terraform workspace show 2> /dev/null) || return workspace=$(terraform workspace show 2> /dev/null) || return
echo "[${workspace}]" TF_INFO="$RESET%{$fg_bold[blue]%}tf:(%{$fg_bold[magenta]%}$workspace%{$fg_bold[blue]%})$RESET "
echo "$TF_INFO"
fi fi
} }