Skip to content

Commit 79068c4

Browse files
Merge pull request #213 from dormunis/feature/terraform-workspace
Added terraform workspace support
2 parents 85aa664 + d4080e4 commit 79068c4

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

scripts/dracula.sh

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ source $current_dir/utils.sh
88
main()
99
{
1010
# set configuration option variables
11+
terraform_label=$(get_tmux_option "@dracula-terraform-label" "")
1112
show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true)
1213
show_location=$(get_tmux_option "@dracula-show-location" true)
1314
fixed_location=$(get_tmux_option "@dracula-fixed-location")
@@ -197,6 +198,10 @@ main()
197198
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray")
198199
script="#($current_dir/kubernetes_context.sh $show_kubernetes_context_label)"
199200

201+
elif [ $plugin = "terraform" ]; then
202+
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-terraform-colors" "light_purple dark_gray")
203+
script="#($current_dir/terraform.sh $terraform_label)"
204+
200205
elif [ $plugin = "weather" ]; then
201206
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-weather-colors" "orange dark_gray")
202207
script="#($current_dir/weather_wrapper.sh $show_fahrenheit $show_location $fixed_location)"

scripts/terraform.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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

0 commit comments

Comments
 (0)