Skip to content

Commit

Permalink
Add Terraform item (#203)
Browse files Browse the repository at this point in the history
* Add Terraform item

* Do not show default workspace in Terraform prompt

* Add terraform to tide_right_prompt_items

* Add terraform to _tide_remove_unusable_items

* Fix test, use read, format

Co-authored-by: Ilan Cosman <[email protected]>
  • Loading branch information
radek-sprta and IlanCosman authored Sep 21, 2021
1 parent 03bffd9 commit 3787c72
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions functions/_tide_item_terraform.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function _tide_item_terraform
if test -d .terraform
terraform workspace show | read -l workspace
test $workspace != default && _tide_print_item terraform $tide_terraform_icon' ' $workspace
end
end
2 changes: 1 addition & 1 deletion functions/_tide_remove_unusable_items.fish
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function _tide_remove_unusable_items
# Remove tool-specific items for tools the machine doesn't have installed
for item in chruby git go kubectl node php rustc virtual_env
for item in chruby git go kubectl node php rustc terraform virtual_env
set -l cli_names $item
switch $item
case virtual_env
Expand Down
5 changes: 4 additions & 1 deletion functions/tide/configure/configs/classic.fish
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ tide_pwd_icon_home
tide_pwd_icon_unwritable ''
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled true
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc php chruby go kubectl vi_mode
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc php chruby go kubectl terraform vi_mode
tide_right_prompt_prefix ''
tide_right_prompt_separator_diff_color ''
tide_right_prompt_separator_same_color ''
Expand All @@ -85,6 +85,9 @@ tide_status_color $_tide_color_dark_green
tide_status_color_failure D70000
tide_status_icon ''
tide_status_icon_failure ''
tide_terraform_bg_color 444444
tide_terraform_color 844FBA
tide_terraform_icon
tide_time_bg_color 444444
tide_time_color 5F8787
tide_time_format '%T'
Expand Down
2 changes: 2 additions & 0 deletions functions/tide/configure/configs/classic_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ tide_status_bg_color black
tide_status_bg_color_failure black
tide_status_color green
tide_status_color_failure red
tide_terraform_bg_color black
tide_terraform_color magenta
tide_time_bg_color black
tide_time_color brblack
tide_vi_mode_bg_color_default black
Expand Down
5 changes: 4 additions & 1 deletion functions/tide/configure/configs/lean.fish
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ tide_pwd_icon_home
tide_pwd_icon_unwritable ''
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled false
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc php chruby go kubectl
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc php chruby go kubectl terraform
tide_right_prompt_prefix ' '
tide_right_prompt_separator_diff_color ' '
tide_right_prompt_separator_same_color ' '
Expand All @@ -85,6 +85,9 @@ tide_status_color $_tide_color_dark_green
tide_status_color_failure D70000
tide_status_icon ''
tide_status_icon_failure ''
tide_terraform_bg_color normal
tide_terraform_color 844FBA
tide_terraform_icon
tide_time_bg_color normal
tide_time_color 5F8787
tide_time_format '%T'
Expand Down
2 changes: 2 additions & 0 deletions functions/tide/configure/configs/lean_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ tide_status_bg_color normal
tide_status_bg_color_failure normal
tide_status_color green
tide_status_color_failure red
tide_terraform_bg_color normal
tide_terraform_color magenta
tide_time_bg_color normal
tide_time_color brblack
tide_vi_mode_bg_color_default normal
Expand Down
5 changes: 4 additions & 1 deletion functions/tide/configure/configs/rainbow.fish
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ tide_pwd_icon_home
tide_pwd_icon_unwritable ''
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled true
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc php chruby go kubectl vi_mode
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc php chruby go kubectl terraform vi_mode
tide_right_prompt_prefix ''
tide_right_prompt_separator_diff_color ''
tide_right_prompt_separator_same_color ''
Expand All @@ -85,6 +85,9 @@ tide_status_color 4E9A06
tide_status_color_failure FFFF00
tide_status_icon ''
tide_status_icon_failure ''
tide_terraform_bg_color 800080
tide_terraform_color 000000
tide_terraform_icon
tide_time_bg_color D3D7CF
tide_time_color 000000
tide_time_format '%T'
Expand Down
2 changes: 2 additions & 0 deletions functions/tide/configure/configs/rainbow_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ tide_status_bg_color black
tide_status_bg_color_failure red
tide_status_color green
tide_status_color_failure bryellow
tide_terraform_bg_color magenta
tide_terraform_color black
tide_time_bg_color white
tide_time_color black
tide_vi_mode_bg_color_default green
Expand Down
19 changes: 19 additions & 0 deletions tests/_tide_item_terraform.test.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# RUN: %fish %s

function _terraform
_tide_decolor (_tide_item_terraform)
end

set -l terraformDir (mktemp -d)
cd $terraformDir

mock terraform "workspace show" "echo default"
_terraform # CHECK:

mkdir .terraform
_terraform # CHECK:

mock terraform "workspace show" "echo test"
_terraform # CHECK: test

rm -r $terraformDir

0 comments on commit 3787c72

Please sign in to comment.