From 6564c857cf0e0d123787c44bb956f43e50d41700 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Thu, 9 May 2024 12:33:59 -0400 Subject: [PATCH] Add recursive tf init function --- zsh/.zshrc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zsh/.zshrc b/zsh/.zshrc index e3313cc..72e417c 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -272,3 +272,14 @@ PROMPT=$PROMPT'%{$(vterm_prompt_end)%}' type navi > /dev/null && eval "$(navi widget zsh)" eval "$(rbenv init - zsh)" + +tf-init-recursive() { + here=$(pwd) + dirs=$(find . -type f -name '*.tf' -exec dirname {} \; | sort | uniq | xargs readlink --canonicalize) + echo $dirs | while read -r dir; do + echo "Initializing Terraform in $dir" + cd $dir + terraform init || break + done + cd $here +}