Automate configuration menu options

This commit is contained in:
Ilan Cosman 2020-07-14 19:10:59 -07:00
parent d6b4cc78c1
commit e9055703e9
26 changed files with 39 additions and 32 deletions

View File

@ -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

View File

@ -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"

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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

View File

@ -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 ''

View File

@ -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

View File

@ -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 ''

View File

@ -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 ''

View File

@ -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]

View File

@ -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'

View File

@ -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'

View File

@ -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]

View File

@ -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

View File

@ -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'

View File

@ -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]

View File

@ -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'

View File

@ -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

View File

@ -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 ''

View File

@ -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

View File

@ -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 ''

View File

@ -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 ''

View File

@ -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]