feat(terraform): add more aliases (#9989)

Closes #9989
This commit is contained in:
mehdicopter 2021-06-19 00:17:40 +02:00 committed by Marc Cornellà
parent 0e399d47b9
commit 659dbb5368
No known key found for this signature in database
GPG Key ID: 0314585E776A9C1B
2 changed files with 35 additions and 16 deletions

View File

@ -1,14 +1,7 @@
## Terraform oh-my-zsh plugin # Terraform plugin
Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently. Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
It adds completion for `terraform`, as well as aliases and a prompt function.
Current as of Terraform v0.13
### Requirements
* [Terraform](https://terraform.io/)
### Usage
To use it, add `terraform` to the plugins array of your `~/.zshrc` file: To use it, add `terraform` to the plugins array of your `~/.zshrc` file:
@ -16,14 +9,34 @@ To use it, add `terraform` to the plugins array of your `~/.zshrc` file:
plugins=(... terraform) plugins=(... terraform)
``` ```
* Type `terraform` into your prompt and hit `TAB` to see available completion options ## Requirements
* Type `tf` into your prompt as a short alias to `terraform`
### Expanding ZSH prompt with current Terraform workspace name * [Terraform](https://terraform.io/)
If you want to get current Terraform workspace name in your ZSH prompt open ## Aliases
your .zsh-theme file and in a chosen place insert:
```shell | Alias | Command |
PROMPT=$'%{$fg[white]%}$(tf_prompt_info)%{$reset_color%} ' | ----- | -------------------- |
| `tf` | `terraform` |
| `tfa` | `terraform apply` |
| `tfd` | `terraform destroy` |
| `tff` | `terraform fmt` |
| `tfi` | `terraform init` |
| `tfp` | `terraform plan` |
| `tfv` | `terraform validate` |
## Prompt function
You can add the current Terraform workspace in your prompt by adding `$(tf_prompt_info)`
to your `PROMPT` or `RPROMPT` variable.
```sh
RPROMPT='$(tf_prompt_info)'
```
You can also specify the PREFIX and SUFFIX for the workspace with the following variables:
```sh
ZSH_THEME_TF_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_TF_PROMPT_SUFFIX="%{$reset_color%}"
``` ```

View File

@ -9,3 +9,9 @@ function tf_prompt_info() {
} }
alias tf='terraform' alias tf='terraform'
alias tfa='terraform apply'
alias tfd='terraform destroy'
alias tff='terraform fmt'
alias tfi='terraform init'
alias tfp='terraform plan'
alias tfv='terraform validate'