Awesome
zsh-terraform
zsh plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
This plugins extends original oh-my-zsh plugin with aliases, functions and autocompletion.
It will also install and load some useful tools :
Table of content
This documentation section is generated automatically
<!--TOC--> <!--TOC-->Requirements
You can install, manage different terraform versions using terraform for example
Usage
- Using Antigen
Bundle zsh-terraform
in your .zshrc
antigen bundle ptavares/zsh-terraform
- Using zplug
Load zsh-terraform
as a plugin in your .zshrc
zplug "ptavares/zsh-terraform"
- Using zgen
Include the load command in your .zshrc
zget load ptavares/zsh-terraform
- As an Oh My ZSH! custom plugin
Clone zsh-terraform
into your custom plugins repo and load as a plugin in your .zshrc
git clone https://github.com/ptavares/zsh-terraform.git ~/.oh-my-zsh/custom/plugins/zsh-terraform
plugins+=(zsh-terraform)
Keep in mind that plugins need to be added before oh-my-zsh.sh
is sourced.
- Manually
Clone this repository somewhere (~/.zsh-terraform
for example) and source it in your .zshrc
git clone https://github.com/ptavares/zsh-terraform ~/.zsh-terraform
source ~/.zsh-terraform/zsh-terraform.plugin.zsh
Aliases
Alias | Command |
---|---|
tf | terraform |
tff | tf fmt |
tfv | tf validate |
tfi | tf init |
tfp | tf plan |
tfa | tf apply |
tfd | tf destroy |
tfo | tf output |
tfr | tf refresh |
tfs | tf show |
tfw | tf workspace |
tffr | tff -recursive |
tfip | tfi & tfp |
tfia | tfi & tfa |
tfid | tfi & tfd |
tfa! | tfa -auto-approve |
tfia! | tfi && tfa! |
tfd! | tfd -auto-approve |
tfid! | tfi && tfd! |
tfversion | tf version |
Function
tfws [workspace_name]
Will execute command :
tfw select [workspace_name] || tfw new [workspace_name]
Prompt function
You can add the current Terraform workspace in your prompt by adding $(tf_prompt_info)
to your PROMPT
or RPROMPT
variable.
RPROMPT` | `$(tf_prompt_info)'
You can also specify the PREFIX and SUFFIX for the workspace with the following variables:
ZSH_THEME_TF_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_TF_PROMPT_SUFFIX="%{$reset_color%}"
Updating Terraform tools
The plugin comes with a zsh function to update all Terraform tools manually
# From zsh shell
update_zsh_terraform