659dbb53680c6f931d8e20d267fe879a37ba42f1

Author
mehdicopter <mmahfoudi@meilleursagents.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

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

Closes #9989

Diff

 1diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md
 2index 9e9f0cdfb273f02dd63d8e44f83c8dc8442739b9..474346dc0e71193bf2fc15b539a12a972add7916 100644
 3--- a/plugins/terraform/README.md
 4+++ b/plugins/terraform/README.md
 5@@ -1,14 +1,7 @@
 6-## Terraform oh-my-zsh plugin
 7+# Terraform plugin
 8 
 9 Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
10-
11-Current as of Terraform v0.13
12-
13-### Requirements
14-
15- * [Terraform](https://terraform.io/)
16-
17-### Usage
18+It adds completion for `terraform`, as well as aliases and a prompt function.
19 
20 To use it, add `terraform` to the plugins array of your `~/.zshrc` file:
21 
22@@ -16,14 +9,34 @@ To use it, add `terraform` to the plugins array of your `~/.zshrc` file:
23 plugins=(... terraform)
24 ```
25 
26- * Type `terraform` into your prompt and hit `TAB` to see available completion options
27- * Type `tf` into your prompt as a short alias to `terraform`
28+## Requirements
29 
30-### Expanding ZSH prompt with current Terraform workspace name
31+* [Terraform](https://terraform.io/)
32 
33-If you want to get current Terraform workspace name in your ZSH prompt open
34-your .zsh-theme file and in a chosen place insert:
35+## Aliases
36 
37-```shell
38-PROMPT=$'%{$fg[white]%}$(tf_prompt_info)%{$reset_color%} '
39+| Alias | Command              |
40+| ----- | -------------------- |
41+| `tf`  | `terraform`          |
42+| `tfa` | `terraform apply`    |
43+| `tfd` | `terraform destroy`  |
44+| `tff` | `terraform fmt`      |
45+| `tfi` | `terraform init`     |
46+| `tfp` | `terraform plan`     |
47+| `tfv` | `terraform validate` |
48+
49+## Prompt function
50+
51+You can add the current Terraform workspace in your prompt by adding `$(tf_prompt_info)`
52+to your `PROMPT` or `RPROMPT` variable.
53+
54+```sh
55+RPROMPT='$(tf_prompt_info)'
56+```
57+
58+You can also specify the PREFIX and SUFFIX for the workspace with the following variables:
59+
60+```sh
61+ZSH_THEME_TF_PROMPT_PREFIX="%{$fg[white]%}"
62+ZSH_THEME_TF_PROMPT_SUFFIX="%{$reset_color%}"
63 ```
64diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh
65index 86b12751cca007f35144a70c9f69ebe88344dbc6..f224b79f0555552ff19949303c4d429d27fcc327 100644
66--- a/plugins/terraform/terraform.plugin.zsh
67+++ b/plugins/terraform/terraform.plugin.zsh
68@@ -9,3 +9,9 @@ function tf_prompt_info() {
69 }
70 
71 alias tf='terraform'
72+alias tfa='terraform apply'
73+alias tfd='terraform destroy'
74+alias tff='terraform fmt'
75+alias tfi='terraform init'
76+alias tfp='terraform plan'
77+alias tfv='terraform validate'