aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-06-24 13:38:18 +0900
committernsfisis <nsfisis@gmail.com>2024-06-24 13:38:18 +0900
commite64ccbf0ca52198f6c0fc222ccb0b026f09f0f18 (patch)
tree183566558e51611f16c761c23e0103734c24bf39
parentcbe0be92936f83f1e668384a491ab91d95fd6462 (diff)
downloaddotfiles-e64ccbf0ca52198f6c0fc222ccb0b026f09f0f18.tar.gz
dotfiles-e64ccbf0ca52198f6c0fc222ccb0b026f09f0f18.tar.zst
dotfiles-e64ccbf0ca52198f6c0fc222ccb0b026f09f0f18.zip
zsh: confirm before executing `terraform apply`
-rw-r--r--.zshrc19
1 files changed, 19 insertions, 0 deletions
diff --git a/.zshrc b/.zshrc
index 74e8cf9..222ab79 100644
--- a/.zshrc
+++ b/.zshrc
@@ -466,3 +466,22 @@ export PATH="$HOME/go/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.deno/bin:$PATH"
export PATH=/usr/local/go/bin:$PATH
+
+
+
+# Confirm before executing `terraform apply`.
+function terraform() {
+ local subcommand="$1"
+ if [[ $subcommand = "apply" ]]; then
+ echo "Are you sure to apply?"
+ echo -n "(y/n): "
+ read -r answer
+ if [[ $answer = "y" ]]; then
+ command terraform "$@"
+ else
+ echo "Cancelled."
+ fi
+ else
+ command terraform "$@"
+ fi
+}