From e64ccbf0ca52198f6c0fc222ccb0b026f09f0f18 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 24 Jun 2024 13:38:18 +0900 Subject: zsh: confirm before executing `terraform apply` --- .zshrc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 +} -- cgit v1.2.3-70-g09d2