fix(terraform): add command guard and document missing aliases

- Add command existence check at the top of the plugin to prevent
  aliases and functions from being created when terraform is not
  installed, consistent with other plugins (e.g. bun, volta, gh)
- Add missing `tfapp` and `tfpo` aliases to the README documentation
This commit is contained in:
fauzan171 2026-06-06 23:45:40 +07:00
parent 70ad5e3df8
commit 7829040e32
2 changed files with 7 additions and 0 deletions

View File

@ -21,6 +21,7 @@ plugins=(... terraform)
| `tfa` | `terraform apply` |
| `tfa!` | `terraform apply -auto-approve` |
| `tfap` | `terraform apply -parallelism=1` |
| `tfapp` | `terraform apply tfplan` |
| `tfc` | `terraform console` |
| `tfd` | `terraform destroy` |
| `tfd!` | `terraform destroy -auto-approve` |
@ -33,6 +34,7 @@ plugins=(... terraform)
| `tfiur` | `terraform init -upgrade -reconfigure` |
| `tfo` | `terraform output` |
| `tfp` | `terraform plan` |
| `tfpo` | `terraform plan -out tfplan` |
| `tfv` | `terraform validate` |
| `tfs` | `terraform state` |
| `tft` | `terraform test` |

View File

@ -1,3 +1,8 @@
# Return immediately if terraform is not found
if (( ! ${+commands[terraform]} )); then
return
fi
function tf_prompt_info() {
# dont show 'default' workspace in home dir
[[ "$PWD" != ~ ]] || return