tide/tide_theme/functions/configure.fish

99 lines
2.3 KiB
Fish
Raw Normal View History

2020-05-19 06:03:25 +03:00
function tide_configure
if test $COLUMNS -lt 55 || test $LINES -lt 21
2020-05-20 00:10:19 +03:00
printf '%s\n' 'Terminal size too small; must be at least 55 x 21'
return 1
end
2020-05-19 02:17:50 +03:00
set -g fake_columns $COLUMNS
if test $fake_columns -gt 100
set -g fake_columns 100
end
set -g fake_lines $LINES
2020-04-28 01:37:08 +03:00
2020-05-20 20:39:44 +03:00
for fn in $_tide_dir/configure/functions/*
2020-05-19 02:17:50 +03:00
source "$fn"
end
2020-05-20 20:39:44 +03:00
for promptItem in $_tide_dir/configure/prompt_items/*
2020-05-19 02:17:50 +03:00
source "$promptItem"
2020-04-28 01:37:08 +03:00
end
_begin
end
function _begin
2020-05-19 02:17:50 +03:00
_set_defaults
_next_choice 'show_time'
end
2020-05-19 02:17:50 +03:00
function _set_defaults
if test $fake_lines -ge 26
2020-05-19 06:03:25 +03:00
set -g fake_tide_newline true
else
2020-05-19 06:03:25 +03:00
set -g fake_tide_newline false
end
2020-05-19 06:03:25 +03:00
set -g fake_tide_left_prompt_items 'pwd' 'git_prompt' 'newline' 'prompt_char'
set -g fake_tide_right_prompt_items 'cmd_duration' 'time'
2020-05-19 06:03:25 +03:00
set -g fake_tide_time_format ''
set -g fake_tide_time_color 5F8787
set -g fake_tide_prompt_connection_icon ' '
set -g fake_tide_prompt_connection_color 6C6C6C
end
2020-05-19 02:17:50 +03:00
function _next_choice -a nextChoice
2020-05-20 20:39:44 +03:00
source "$_tide_dir/configure/choices/$nextChoice.fish"
2020-05-19 02:17:50 +03:00
$nextChoice
end
2020-05-19 02:17:50 +03:00
function _menu -a question options
set -l optionList (string split '/' $options)
set -l bold (set_color -o)
set -l norm (set_color normal)
2020-04-21 06:35:56 +03:00
2020-05-19 02:17:50 +03:00
while true
read -P $bold"$question [$options] "$norm input
2020-05-19 02:17:50 +03:00
if contains $input $optionList
2020-05-20 00:10:19 +03:00
printf '%s\n' $input
2020-05-19 02:17:50 +03:00
break
end
2020-04-21 21:52:24 +03:00
end
end
2020-05-19 02:17:50 +03:00
function _title -a text
clear
2020-05-19 02:17:50 +03:00
set -l midCols (math -s0 $fake_columns/2)
set -l midTitle (math -s0 (string length $text)/2)
2020-05-19 02:17:50 +03:00
_cursor_right (math $midCols-$midTitle)
2020-04-21 21:52:24 +03:00
set_color -o
2020-05-20 00:10:19 +03:00
printf '%s\n' $text
2020-04-21 21:52:24 +03:00
set_color normal
end
function _option -a symbol text
2020-04-21 21:52:24 +03:00
set_color -o
2020-05-20 00:10:19 +03:00
printf '%s\n' "($symbol) $text"
2020-04-21 21:52:24 +03:00
set_color normal
end
2020-05-19 02:17:50 +03:00
function _display_prompt -a var_name var_value
if test -n "$var_name"
set -g $var_name $var_value
end
2020-04-21 06:35:56 +03:00
fake_prompt
2020-04-30 00:52:58 +03:00
printf '\n\n'
end
2020-05-19 02:17:50 +03:00
function _display_restart_and_quit
printf '(r) Restart from the beginning \n\n'
printf '(q) Quit and do nothing \n\n'
end
2020-05-09 08:48:35 +03:00
function _quit --on-signal INT
2020-05-19 02:17:50 +03:00
source "$__fish_config_dir/functions/fish_prompt.fish"
2020-05-20 20:05:33 +03:00
source "$__fish_config_dir/functions/_tide_left_prompt.fish"
source "$__fish_config_dir/functions/_tide_right_prompt.fish"
clear
end