terraform.sh
1 #!/usr/bin/env bash 2 # setting the locale, some users have issues with different locales, this forces the correct one 3 export LC_ALL=en_US.UTF-8 4 5 label=$1 6 7 current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 8 source $current_dir/utils.sh 9 10 main() { 11 # storing the refresh rate in the variable RATE, default is 5 12 RATE=$(get_tmux_option "@dracula-refresh-rate" 5) 13 OUTPUT_STRING="N/A" 14 terraform_dir="$(tmux display-message -p '#{pane_current_path}')/.terraform" 15 if [ -d $terraform_dir ]; then 16 current_workspace=$(terraform workspace show 2>/dev/null) 17 OUTPUT_STRING="${current_workspace}" 18 fi 19 if [ "$label" = "" ] 20 then 21 echo "⚙️ ${OUTPUT_STRING}" 22 else 23 echo "⚙️ ${label} ${OUTPUT_STRING}" 24 fi 25 26 sleep $RATE 27 } 28 29 # run the main driver 30 main