From e954a609ac54a995a5b8296d9b99dba35dad42ed Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Sun, 7 Mar 2021 21:43:39 -0800 Subject: [PATCH] Make status item smarter, remove tide_status_always_display --- functions/_tide_item_status.fish | 4 +- .../tide/configure/choices/all/finish.fish | 2 - functions/tide/configure/configs/classic.fish | 1 - functions/tide/configure/configs/lean.fish | 1 - functions/tide/configure/configs/rainbow.fish | 1 - tests/_tide_item_status.test.fish | 56 ++++++++----------- 6 files changed, 25 insertions(+), 40 deletions(-) diff --git a/functions/_tide_item_status.fish b/functions/_tide_item_status.fish index fa74851..3e2efe7 100644 --- a/functions/_tide_item_status.fish +++ b/functions/_tide_item_status.fish @@ -1,7 +1,7 @@ function _tide_item_status if string match --quiet --invert 0 $_tide_last_pipestatus # If there is a failure anywhere in the pipestatus if test "$_tide_last_pipestatus" = 1 # If simple failure - if test "$tide_status_always_display" = true + if not contains prompt_char $tide_left_prompt_items set -g tide_status_bg_color $tide_status_failure_bg_color set_color $tide_status_failure_color printf '%s' $tide_status_failure_icon' ' 1 @@ -19,7 +19,7 @@ function _tide_item_status fish_status_to_signal $_tide_last_pipestatus | string replace SIG '' | string join '|' end - else if test "$tide_status_always_display" = true + else if not contains prompt_char $tide_left_prompt_items set -g tide_status_bg_color $tide_status_success_bg_color set_color $tide_status_success_color printf '%s' $tide_status_success_icon diff --git a/functions/tide/configure/choices/all/finish.fish b/functions/tide/configure/choices/all/finish.fish index 36e670c..9bcc8b1 100644 --- a/functions/tide/configure/choices/all/finish.fish +++ b/functions/tide/configure/choices/all/finish.fish @@ -43,8 +43,6 @@ function _tide_finish if contains prompt_char $fake_tide_left_prompt_items _find_and_remove vi_mode fake_tide_right_prompt_items else - set fake_tide_status_always_display true # Without a prompt_char, the user won't know if a command failed/succeeded - # If no prompt_char, insert vi_mode _find_and_remove vi_mode fake_tide_right_prompt_items if contains time $fake_tide_right_prompt_items diff --git a/functions/tide/configure/configs/classic.fish b/functions/tide/configure/configs/classic.fish index ebec8ad..3e5fc23 100644 --- a/functions/tide/configure/configs/classic.fish +++ b/functions/tide/configure/configs/classic.fish @@ -73,7 +73,6 @@ tide_chruby_icon '' tide_rust_bg_color 444444 tide_rust_color 00AFAF tide_rust_icon '' -tide_status_always_display false tide_status_failure_bg_color 444444 tide_status_failure_color D70000 tide_status_failure_icon '✘' diff --git a/functions/tide/configure/configs/lean.fish b/functions/tide/configure/configs/lean.fish index 8c427d5..0173ed5 100644 --- a/functions/tide/configure/configs/lean.fish +++ b/functions/tide/configure/configs/lean.fish @@ -73,7 +73,6 @@ tide_chruby_icon '' tide_rust_bg_color normal tide_rust_color 00AFAF tide_rust_icon '' -tide_status_always_display false tide_status_failure_bg_color normal tide_status_failure_color D70000 tide_status_failure_icon '✘' diff --git a/functions/tide/configure/configs/rainbow.fish b/functions/tide/configure/configs/rainbow.fish index 1ae2d36..064c668 100644 --- a/functions/tide/configure/configs/rainbow.fish +++ b/functions/tide/configure/configs/rainbow.fish @@ -73,7 +73,6 @@ tide_chruby_icon '' tide_rust_bg_color FF8700 tide_rust_color 2E3436 tide_rust_icon '' -tide_status_always_display false tide_status_failure_bg_color CC0000 tide_status_failure_color FFFF00 tide_status_failure_icon '✘' diff --git a/tests/_tide_item_status.test.fish b/tests/_tide_item_status.test.fish index 9c219f6..cba5a0d 100644 --- a/tests/_tide_item_status.test.fish +++ b/tests/_tide_item_status.test.fish @@ -5,42 +5,11 @@ function _status _tide_decolor (_tide_item_status) end - -set -lx tide_status_success_icon -set -lx tide_status_failure_icon - -true | false -_status # CHECK: 0|1 - -false | true -_status # CHECK: 1|0 - set -lx tide_status_success_icon '✔' set -lx tide_status_failure_icon '✘' - -set -lx tide_status_always_display false - -true -_status # CHECK: - -false -_status # CHECK: - -true | false -_status # CHECK: ✘ 0|1 - -true | true -_status # CHECK: - -false | true -_status # CHECK: ✔ 1|0 - -false | false -_status # CHECK: ✘ 1|1 - - -set -lx tide_status_always_display true +# Without prompt_char +set -lx tide_left_prompt_items true _status # CHECK: ✔ @@ -59,3 +28,24 @@ _status # CHECK: ✔ 1|0 false | false _status # CHECK: ✘ 1|1 + +# With prompt_char +set -lx tide_left_prompt_items prompt_char + +true +_status # CHECK: + +false +_status # CHECK: + +true | false +_status # CHECK: ✘ 0|1 + +true | true +_status # CHECK: + +false | true +_status # CHECK: ✔ 1|0 + +false | false +_status # CHECK: ✘ 1|1