Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added terraform workspace support #213

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions scripts/dracula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ source $current_dir/utils.sh
main()
{
# set configuration option variables
terraform_label=$(get_tmux_option "@dracula-terraform-label" "")
show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true)
show_location=$(get_tmux_option "@dracula-show-location" true)
fixed_location=$(get_tmux_option "@dracula-fixed-location")
Expand Down Expand Up @@ -197,6 +198,10 @@ main()
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray")
script="#($current_dir/kubernetes_context.sh $show_kubernetes_context_label)"

elif [ $plugin = "terraform" ]; then
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-terraform-colors" "light_purple dark_gray")
script="#($current_dir/terraform.sh $terraform_label)"

elif [ $plugin = "weather" ]; then
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-weather-colors" "orange dark_gray")
script="#($current_dir/weather_wrapper.sh $show_fahrenheit $show_location $fixed_location)"
Expand Down
30 changes: 30 additions & 0 deletions scripts/terraform.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# setting the locale, some users have issues with different locales, this forces the correct one
export LC_ALL=en_US.UTF-8

label=$1

current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $current_dir/utils.sh

main() {
# storing the refresh rate in the variable RATE, default is 5
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
OUTPUT_STRING="N/A"
terraform_dir="$(tmux display-message -p '#{pane_current_path}')/.terraform"
if [ -d $terraform_dir ]; then
current_workspace=$(terraform workspace show 2>/dev/null)
OUTPUT_STRING="${current_workspace}"
fi
if [ "$label" = "" ]
then
echo "⚙️ ${OUTPUT_STRING}"
else
echo "⚙️ ${label} ${OUTPUT_STRING}"
fi

sleep $RATE
}

# run the main driver
main