From e9055703e9f8003d8743fbf9b942bcb2e280ebd4 Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Tue, 14 Jul 2020 19:10:59 -0700 Subject: [PATCH] Automate configuration menu options --- functions/_tide_sub_configure.fish | 19 +++++++++++++------ tide_theme/configure/choices/all/finish.fish | 4 ++-- .../prompt_connection_andor_frame_color.fish | 2 +- .../configure/choices/all/prompt_spacing.fish | 2 +- tide_theme/configure/choices/all/style.fish | 2 +- .../choices/classic/classic_prompt_color.fish | 2 +- .../classic/classic_prompt_connection.fish | 2 +- .../choices/classic/classic_prompt_frame.fish | 2 +- .../choices/classic/classic_prompt_heads.fish | 2 +- .../classic/classic_prompt_height.fish | 2 +- .../classic/classic_prompt_separators.fish | 2 +- .../choices/classic/classic_prompt_tails.fish | 2 +- .../choices/classic/classic_show_time.fish | 2 +- .../choices/lean/lean_prompt_connection.fish | 2 +- .../choices/lean/lean_prompt_height.fish | 2 +- .../choices/lean/lean_show_time.fish | 2 +- .../pure/pure_nonperm_content_location.fish | 2 +- .../choices/pure/pure_prompt_height.fish | 2 +- .../choices/pure/pure_show_time.fish | 2 +- .../rainbow/rainbow_prompt_connection.fish | 2 +- .../choices/rainbow/rainbow_prompt_frame.fish | 2 +- .../choices/rainbow/rainbow_prompt_heads.fish | 2 +- .../rainbow/rainbow_prompt_height.fish | 2 +- .../rainbow/rainbow_prompt_separators.fish | 2 +- .../choices/rainbow/rainbow_prompt_tails.fish | 2 +- .../choices/rainbow/rainbow_show_time.fish | 2 +- 26 files changed, 39 insertions(+), 32 deletions(-) diff --git a/functions/_tide_sub_configure.fish b/functions/_tide_sub_configure.fish index 4075e6d..ddd8b03 100644 --- a/functions/_tide_sub_configure.fish +++ b/functions/_tide_sub_configure.fish @@ -30,16 +30,18 @@ function _next_choice -a nextChoice $cmd end -function _menu -a question options - set -l optionList (string split '/' $options) +function _menu set -l bold (set_color -o) set -l norm (set_color normal) - while true - read -P $bold"$question [$options] "$norm input + set -l listWithSlashes (string join '/' $_option_list) - if contains $input $optionList + while true + read -P $bold"Choice [$listWithSlashes] "$norm input + + if contains $input $_option_list printf '%s\n' $input + set -e _option_list break end end @@ -57,6 +59,8 @@ function _title -a text end function _option -a symbol text + set -ga _option_list $symbol + set_color -o printf '%s\n' "($symbol) $text" set_color normal @@ -72,7 +76,10 @@ end function _display_restart_and_quit printf '%s\n' '(r) Restart from the beginning' - printf '%s\n\n' '(q) Quit and do nothing' + printf '%s\n' '(q) Quit and do nothing' + printf '%s\n' '' + + set -ga _option_list r q end function _quit --on-signal INT diff --git a/tide_theme/configure/choices/all/finish.fish b/tide_theme/configure/choices/all/finish.fish index f45534f..af3b5a0 100644 --- a/tide_theme/configure/choices/all/finish.fish +++ b/tide_theme/configure/choices/all/finish.fish @@ -1,7 +1,7 @@ function finish set_color red _title 'Overwrite tide config and fish_prompt?' - # set_color normal + set_color normal _option y 'Yes' printf '%b' '\n\n' @@ -9,7 +9,7 @@ function finish _option n 'No' printf '%b' '\n\n' - switch (_menu 'Choice' y/n) + switch (_menu) case y cat "$_tide_dir/configure/fish_prompt.fish" >"$__fish_config_dir/functions/fish_prompt.fish" diff --git a/tide_theme/configure/choices/all/prompt_connection_andor_frame_color.fish b/tide_theme/configure/choices/all/prompt_connection_andor_frame_color.fish index e5dda69..7adeb8e 100644 --- a/tide_theme/configure/choices/all/prompt_connection_andor_frame_color.fish +++ b/tide_theme/configure/choices/all/prompt_connection_andor_frame_color.fish @@ -37,7 +37,7 @@ function prompt_connection_andor_frame_color _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/r/q) + switch (_menu) case 1 _set_prompt_connection_and_frame_color 808080 _next_choice 'all/prompt_spacing' diff --git a/tide_theme/configure/choices/all/prompt_spacing.fish b/tide_theme/configure/choices/all/prompt_spacing.fish index b83df9e..91ee8ed 100644 --- a/tide_theme/configure/choices/all/prompt_spacing.fish +++ b/tide_theme/configure/choices/all/prompt_spacing.fish @@ -12,7 +12,7 @@ function prompt_spacing _display_restart_and_quit - switch (_menu 'Choice' 1/2/r/q) + switch (_menu) case 1 set -g fake_tide_print_newline_before_prompt false _next_choice 'all/finish' diff --git a/tide_theme/configure/choices/all/style.fish b/tide_theme/configure/choices/all/style.fish index c78b62f..dde1f50 100644 --- a/tide_theme/configure/choices/all/style.fish +++ b/tide_theme/configure/choices/all/style.fish @@ -19,7 +19,7 @@ function style _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/r/q) + switch (_menu) case 1 _load_config lean _next_choice 'lean/lean_show_time' diff --git a/tide_theme/configure/choices/classic/classic_prompt_color.fish b/tide_theme/configure/choices/classic/classic_prompt_color.fish index add9e19..d0aabeb 100644 --- a/tide_theme/configure/choices/classic/classic_prompt_color.fish +++ b/tide_theme/configure/choices/classic/classic_prompt_color.fish @@ -19,7 +19,7 @@ function classic_prompt_color _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/r/q) + switch (_menu) case 1 _set_all_items_bg_color 585858 _next_choice 'classic/classic_show_time' diff --git a/tide_theme/configure/choices/classic/classic_prompt_connection.fish b/tide_theme/configure/choices/classic/classic_prompt_connection.fish index 88258f4..640a2da 100644 --- a/tide_theme/configure/choices/classic/classic_prompt_connection.fish +++ b/tide_theme/configure/choices/classic/classic_prompt_connection.fish @@ -12,7 +12,7 @@ function classic_prompt_connection _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/r/q) + switch (_menu) case 1 set -g fake_tide_prompt_connection_icon '' _next_choice 'classic/classic_prompt_frame' diff --git a/tide_theme/configure/choices/classic/classic_prompt_frame.fish b/tide_theme/configure/choices/classic/classic_prompt_frame.fish index 2b244d6..15aab98 100644 --- a/tide_theme/configure/choices/classic/classic_prompt_frame.fish +++ b/tide_theme/configure/choices/classic/classic_prompt_frame.fish @@ -27,7 +27,7 @@ function classic_prompt_frame _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/r/q) + switch (_menu) case 1 set fake_tide_left_prompt_frame_enabled false set fake_tide_right_prompt_frame_enabled false diff --git a/tide_theme/configure/choices/classic/classic_prompt_heads.fish b/tide_theme/configure/choices/classic/classic_prompt_heads.fish index 118801b..bb364f9 100644 --- a/tide_theme/configure/choices/classic/classic_prompt_heads.fish +++ b/tide_theme/configure/choices/classic/classic_prompt_heads.fish @@ -23,7 +23,7 @@ function classic_prompt_heads _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/r/q) + switch (_menu) case 1 set -g fake_tide_left_prompt_suffix '' set -g fake_tide_right_prompt_prefix '' diff --git a/tide_theme/configure/choices/classic/classic_prompt_height.fish b/tide_theme/configure/choices/classic/classic_prompt_height.fish index 031bfcd..27f5917 100644 --- a/tide_theme/configure/choices/classic/classic_prompt_height.fish +++ b/tide_theme/configure/choices/classic/classic_prompt_height.fish @@ -15,7 +15,7 @@ function classic_prompt_height _display_restart_and_quit - switch (_menu 'Choice' 1/2/r/q) + switch (_menu) case 1 set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)] set fake_tide_left_prompt_frame_enabled false diff --git a/tide_theme/configure/choices/classic/classic_prompt_separators.fish b/tide_theme/configure/choices/classic/classic_prompt_separators.fish index 765a847..b2d70cd 100644 --- a/tide_theme/configure/choices/classic/classic_prompt_separators.fish +++ b/tide_theme/configure/choices/classic/classic_prompt_separators.fish @@ -23,7 +23,7 @@ function classic_prompt_separators _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/r/q) + switch (_menu) case 1 set -g fake_tide_left_prompt_item_separator_same_color '' set -g fake_tide_right_prompt_item_separator_same_color '' diff --git a/tide_theme/configure/choices/classic/classic_prompt_tails.fish b/tide_theme/configure/choices/classic/classic_prompt_tails.fish index 2bc32ed..d685da3 100644 --- a/tide_theme/configure/choices/classic/classic_prompt_tails.fish +++ b/tide_theme/configure/choices/classic/classic_prompt_tails.fish @@ -28,7 +28,7 @@ function classic_prompt_tails _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/5/r/q) + switch (_menu) case 1 set -g fake_tide_left_prompt_prefix '' set -g fake_tide_right_prompt_suffix '' diff --git a/tide_theme/configure/choices/classic/classic_show_time.fish b/tide_theme/configure/choices/classic/classic_show_time.fish index 4da6d47..067372f 100644 --- a/tide_theme/configure/choices/classic/classic_show_time.fish +++ b/tide_theme/configure/choices/classic/classic_show_time.fish @@ -14,7 +14,7 @@ function classic_show_time _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/r/q) + switch (_menu) case 1 set -g fake_tide_time_format '' set -e fake_tide_right_prompt_items[-1] diff --git a/tide_theme/configure/choices/lean/lean_prompt_connection.fish b/tide_theme/configure/choices/lean/lean_prompt_connection.fish index 473a4d4..20adbfc 100644 --- a/tide_theme/configure/choices/lean/lean_prompt_connection.fish +++ b/tide_theme/configure/choices/lean/lean_prompt_connection.fish @@ -12,7 +12,7 @@ function lean_prompt_connection _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/r/q) + switch (_menu) case 1 set -g fake_tide_prompt_connection_icon '' _next_choice 'all/prompt_connection_andor_frame_color' diff --git a/tide_theme/configure/choices/lean/lean_prompt_height.fish b/tide_theme/configure/choices/lean/lean_prompt_height.fish index c8657fa..c1fbaed 100644 --- a/tide_theme/configure/choices/lean/lean_prompt_height.fish +++ b/tide_theme/configure/choices/lean/lean_prompt_height.fish @@ -11,7 +11,7 @@ function lean_prompt_height _display_restart_and_quit - switch (_menu 'Choice' 1/2/r/q) + switch (_menu) case 1 set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)] _next_choice 'all/prompt_connection_andor_frame_color' diff --git a/tide_theme/configure/choices/lean/lean_show_time.fish b/tide_theme/configure/choices/lean/lean_show_time.fish index e871de8..6bf98cd 100644 --- a/tide_theme/configure/choices/lean/lean_show_time.fish +++ b/tide_theme/configure/choices/lean/lean_show_time.fish @@ -14,7 +14,7 @@ function lean_show_time _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/r/q) + switch (_menu) case 1 set -g fake_tide_time_format '' set -e fake_tide_right_prompt_items[-1] diff --git a/tide_theme/configure/choices/pure/pure_nonperm_content_location.fish b/tide_theme/configure/choices/pure/pure_nonperm_content_location.fish index 1214d0c..35e83cf 100644 --- a/tide_theme/configure/choices/pure/pure_nonperm_content_location.fish +++ b/tide_theme/configure/choices/pure/pure_nonperm_content_location.fish @@ -12,7 +12,7 @@ function pure_nonperm_content_location _display_restart_and_quit - switch (_menu 'Choice' 1/2/r/q) + switch (_menu) case 1 set -g fake_tide_left_prompt_items 'pwd' 'git_prompt' 'cmd_duration' 'newline' 'prompt_char' set -g fake_tide_right_prompt_items diff --git a/tide_theme/configure/choices/pure/pure_prompt_height.fish b/tide_theme/configure/choices/pure/pure_prompt_height.fish index c7bf0e5..d1fadb3 100644 --- a/tide_theme/configure/choices/pure/pure_prompt_height.fish +++ b/tide_theme/configure/choices/pure/pure_prompt_height.fish @@ -11,7 +11,7 @@ function pure_prompt_height _display_restart_and_quit - switch (_menu 'Choice' 1/2/r/q) + switch (_menu) case 1 set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)] _next_choice 'all/prompt_connection_andor_frame_color' diff --git a/tide_theme/configure/choices/pure/pure_show_time.fish b/tide_theme/configure/choices/pure/pure_show_time.fish index 3bc2410..6ed373a 100644 --- a/tide_theme/configure/choices/pure/pure_show_time.fish +++ b/tide_theme/configure/choices/pure/pure_show_time.fish @@ -14,7 +14,7 @@ function pure_show_time _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/r/q) + switch (_menu) case 1 set -g fake_tide_time_format '' set -e fake_tide_right_prompt_items[-1] diff --git a/tide_theme/configure/choices/rainbow/rainbow_prompt_connection.fish b/tide_theme/configure/choices/rainbow/rainbow_prompt_connection.fish index eb4c3c7..6f33ee8 100644 --- a/tide_theme/configure/choices/rainbow/rainbow_prompt_connection.fish +++ b/tide_theme/configure/choices/rainbow/rainbow_prompt_connection.fish @@ -12,7 +12,7 @@ function rainbow_prompt_connection _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/r/q) + switch (_menu) case 1 set -g fake_tide_prompt_connection_icon '' _next_choice 'rainbow/rainbow_prompt_frame' diff --git a/tide_theme/configure/choices/rainbow/rainbow_prompt_frame.fish b/tide_theme/configure/choices/rainbow/rainbow_prompt_frame.fish index 878103b..feb2643 100644 --- a/tide_theme/configure/choices/rainbow/rainbow_prompt_frame.fish +++ b/tide_theme/configure/choices/rainbow/rainbow_prompt_frame.fish @@ -27,7 +27,7 @@ function rainbow_prompt_frame _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/r/q) + switch (_menu) case 1 set fake_tide_left_prompt_frame_enabled false set fake_tide_right_prompt_frame_enabled false diff --git a/tide_theme/configure/choices/rainbow/rainbow_prompt_heads.fish b/tide_theme/configure/choices/rainbow/rainbow_prompt_heads.fish index 6eaf414..762e0ae 100644 --- a/tide_theme/configure/choices/rainbow/rainbow_prompt_heads.fish +++ b/tide_theme/configure/choices/rainbow/rainbow_prompt_heads.fish @@ -23,7 +23,7 @@ function rainbow_prompt_heads _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/r/q) + switch (_menu) case 1 set -g fake_tide_left_prompt_suffix '' set -g fake_tide_right_prompt_prefix '' diff --git a/tide_theme/configure/choices/rainbow/rainbow_prompt_height.fish b/tide_theme/configure/choices/rainbow/rainbow_prompt_height.fish index 897735f..5584762 100644 --- a/tide_theme/configure/choices/rainbow/rainbow_prompt_height.fish +++ b/tide_theme/configure/choices/rainbow/rainbow_prompt_height.fish @@ -15,7 +15,7 @@ function rainbow_prompt_height _display_restart_and_quit - switch (_menu 'Choice' 1/2/r/q) + switch (_menu) case 1 set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)] set fake_tide_left_prompt_frame_enabled false diff --git a/tide_theme/configure/choices/rainbow/rainbow_prompt_separators.fish b/tide_theme/configure/choices/rainbow/rainbow_prompt_separators.fish index bab0ee5..1f2f507 100644 --- a/tide_theme/configure/choices/rainbow/rainbow_prompt_separators.fish +++ b/tide_theme/configure/choices/rainbow/rainbow_prompt_separators.fish @@ -23,7 +23,7 @@ function rainbow_prompt_separators _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/r/q) + switch (_menu) case 1 set -g fake_tide_left_prompt_item_separator_diff_color '' set -g fake_tide_right_prompt_item_separator_diff_color '' diff --git a/tide_theme/configure/choices/rainbow/rainbow_prompt_tails.fish b/tide_theme/configure/choices/rainbow/rainbow_prompt_tails.fish index 27dd0b0..6ea120e 100644 --- a/tide_theme/configure/choices/rainbow/rainbow_prompt_tails.fish +++ b/tide_theme/configure/choices/rainbow/rainbow_prompt_tails.fish @@ -28,7 +28,7 @@ function rainbow_prompt_tails _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/4/5/r/q) + switch (_menu) case 1 set -g fake_tide_left_prompt_prefix '' set -g fake_tide_right_prompt_suffix '' diff --git a/tide_theme/configure/choices/rainbow/rainbow_show_time.fish b/tide_theme/configure/choices/rainbow/rainbow_show_time.fish index b60210e..7eac166 100644 --- a/tide_theme/configure/choices/rainbow/rainbow_show_time.fish +++ b/tide_theme/configure/choices/rainbow/rainbow_show_time.fish @@ -14,7 +14,7 @@ function rainbow_show_time _display_restart_and_quit - switch (_menu 'Choice' 1/2/3/r/q) + switch (_menu) case 1 set -g fake_tide_time_format '' set -e fake_tide_right_prompt_items[-1]