From f717a91f55f4d5dfb89d8828dc5b36fcc45548c2 Mon Sep 17 00:00:00 2001 From: Alejandro Gandara Date: Wed, 14 Jul 2021 22:52:22 +0100 Subject: * Added new module for showing in prompt the active terraform version. * Prompt shows, the terraform version in this format: Terraform v0.12.13 . If only if a valid terraform command is used, or an alias to it. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The use case: We have a need to constantly change between terraform versions depending on what project we are working on, it is easy to by mistake upgrade the wrong project to the latest terraform version. This is why the prompt is shown in red as soon as you type terraform, this is a good way to remind you to double check this is the terraform version you want to use. Future improvements: Detect current terraform version by checking the terraform workspace state version, and change the terraform color prompt from red to green if you're using the same version. --- internal/p10k.zsh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'internal') diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 935a86d9..07cc280a 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4887,6 +4887,15 @@ _p9k_prompt_terraform_init() { typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[terraform]' } +function prompt_terraform_version() { + local terraform_version="$(command terraform --version)" + _p9k_prompt_segment "$0$state" $_p9k_color1 red TERRAFORM_ICON 0 '' $terraform_version +} + +_p9k_prompt_terraform_version_init() { + typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[terraform]' +} + function prompt_proxy() { local -U p=( $all_proxy $http_proxy $https_proxy $ftp_proxy -- cgit v1.2.3