tfutils / tfenv

Terraform version manager
MIT License
4.42k stars 446 forks source link

Feature Request: Create TFENV_TF_VERSION #405

Open bytebeast opened 11 months ago

bytebeast commented 11 months ago

Feature Request:

Create TFENV_TF_VERSION variable that has current selected version. So that I may use that in my prompt.

Thanks.

next-jesusmanuelnavarro commented 9 months ago

Wouldn't terraform --version itself suffice? i.e.:

$ terraform --version --json | jq -r .terraform_version
1.5.5
$

Note that tfenv is meant to "dynamically" load Terraform, so it may happen that no terraform at all is activated at any given prompt, i.e.:

$ terraform --version --json | jq -r .terraform_version
Specifically asked for min-required via terraform{required_version}, but none found
$

You can even run into a prompt where not even tfenv is active, i.e.:

$ terraform --version --json | jq -r .terraform_version

Command 'terraform' not found
$

You'll have to cope with that case one way or the other.

mengesb commented 9 months ago

Maybe https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/terraform is what you're looking for?