Lots of work on classic configuration

This commit is contained in:
Ilan Cosman 2020-07-07 15:55:11 -07:00
parent bd77cf84dc
commit fbe3a8dd23
19 changed files with 443 additions and 56 deletions

View File

@ -49,7 +49,7 @@ function _fetch_right_prompt_items
set lastItemWasNewline # Display prefix instead of separator before first item
set color normal
printf '%s' ' ' # Necessary for some reason
set_color normal
for item in $tide_right_prompt_items
if test "$item" = 'newline'

View File

@ -1,22 +1,29 @@
function style
_title 'Style'
_title 'Prompt Style'
_option 1 'Lean'
_load_config "$_tide_dir/configure/configs/lean.fish"
_load_config 'lean'
_display_prompt
_option 2 'Pure'
_load_config "$_tide_dir/configure/configs/pure.fish"
_option 2 'Classic'
_load_config 'classic'
_display_prompt
_option 3 'Pure'
_load_config 'pure'
_display_prompt
_display_restart_and_quit
switch (_menu 'Choice' 1/2/r/q)
switch (_menu 'Choice' 1/2/3/r/q)
case 1
_load_config "$_tide_dir/configure/configs/lean.fish"
_load_config lean
_next_choice 'lean/lean_show_time'
case 2
_load_config "$_tide_dir/configure/configs/pure.fish"
_load_config classic
_next_choice 'classic/classic_prompt_color'
case 3
_load_config pure
_next_choice 'pure/pure_nonperm_content_location'
case r
_begin
@ -25,14 +32,14 @@ function style
end
end
function _load_config -a file
function _load_config -a name
for var in $fake_tide_var_list
set -e $var
end
set -g fake_tide_var_list
source $file
source "$_tide_dir/configure/configs/$name.fish"
end
function _set -a var_name

View File

@ -0,0 +1,51 @@
function classic_prompt_color
_title 'Prompt Color'
_option 1 'Lightest'
_set_all_items_bg_color 585858
_display_prompt
_option 2 'Light'
_set_all_items_bg_color 444444
_display_prompt
_option 3 'Dark'
_set_all_items_bg_color 303030
_display_prompt
_option 4 'Darkest'
_set_all_items_bg_color 1C1C1C
_display_prompt
_display_restart_and_quit
switch (_menu 'Choice' 1/2/3/4/r/q)
case 1
_set_all_items_bg_color 585858
_next_choice 'classic/classic_show_time'
case 2
_set_all_items_bg_color 444444
_next_choice 'classic/classic_show_time'
case 3
_set_all_items_bg_color 303030
_next_choice 'classic/classic_show_time'
case 4
_set_all_items_bg_color 1C1C1C
_next_choice 'classic/classic_show_time'
case r
_begin
case q
_quit
end
end
function _set_all_items_bg_color -a color
set fake_tide_cmd_duration_bg_color $color
set fake_tide_context_bg_color $color
set fake_tide_git_prompt_bg_color $color
set fake_tide_jobs_bg_color $color
set fake_tide_pwd_bg_color $color
set fake_tide_status_bg_color $color
set fake_tide_time_bg_color $color
set fake_tide_virtual_env_bg_color $color
end

View File

@ -0,0 +1,42 @@
function classic_prompt_separators
_title 'Prompt Separators'
_option 1 'Angled'
set -g fake_tide_left_prompt_item_separator_same_color ''
set -g fake_tide_right_prompt_item_separator_same_color ''
_display_prompt
_option 2 'Vertical'
set -g fake_tide_left_prompt_item_separator_same_color '│'
set -g fake_tide_right_prompt_item_separator_same_color '│'
_display_prompt
_option 3 'Slanted'
set -g fake_tide_left_prompt_item_separator_same_color ''
set -g fake_tide_right_prompt_item_separator_same_color ''
_display_prompt
_option 4 'Round'
set -g fake_tide_left_prompt_item_separator_same_color ''
set -g fake_tide_right_prompt_item_separator_same_color ''
_display_prompt
_display_restart_and_quit
switch (_menu 'Choice' 1/2/3/r/q)
case 1
set -g fake_tide_time_format ''
set -e fake_tide_right_prompt_items[-1]
_next_choice 'classic/classic_prompt_color'
case 2
set -g fake_tide_time_format '%T'
_next_choice 'classic/classic_prompt_color'
case 3
set -g fake_tide_time_format '%r'
_next_choice 'classic/classic_prompt_color'
case r
_begin
case q
_quit
end
end

View File

@ -0,0 +1,33 @@
function classic_show_time
_title 'Show current time?'
_option 1 'No'
_display_prompt
set -a fake_tide_right_prompt_items 'time'
_option 2 '24-hour format'
_display_prompt fake_tide_time_format '%T'
_option 3 '12-hour format'
_display_prompt fake_tide_time_format '%r'
_display_restart_and_quit
switch (_menu 'Choice' 1/2/3/r/q)
case 1
set -g fake_tide_time_format ''
set -e fake_tide_right_prompt_items[-1]
_next_choice 'classic/classic_prompt_separators'
case 2
set -g fake_tide_time_format '%T'
_next_choice 'classic/classic_prompt_separators'
case 3
set -g fake_tide_time_format '%r'
_next_choice 'classic/classic_prompt_separators'
case r
_begin
case q
_quit
end
end

View File

@ -1,11 +1,11 @@
function lean_show_time
set -a fake_tide_right_prompt_items 'time'
_title 'Show current time?'
_option 1 'No'
_display_prompt fake_tide_time_format ''
_display_prompt
set -a fake_tide_right_prompt_items 'time'
_option 2 '24-hour format'
_display_prompt fake_tide_time_format '%T'

View File

@ -1,10 +1,10 @@
function pure_show_time
set -a fake_tide_right_prompt_items 'time'
_title 'Show current time?'
_option 1 'No'
_display_prompt fake_tide_time_format ''
_display_prompt
set -a fake_tide_right_prompt_items 'time'
_option 2 '24-hour format'
_display_prompt fake_tide_time_format '%T'

View File

@ -0,0 +1,97 @@
# -------------------Local Variables-------------------
set -l tideColorGold D7AF00
set -l tideColorDarkerGreen 5FAF00
# ---------------General Theme Variables---------------
_set fake_tide_print_newline_before_prompt 'true'
# ------------Left Prompt------------
_set fake_tide_left_prompt_items 'pwd' 'git_prompt' 'newline'
_set fake_tide_left_prompt_pad_items true
_set fake_tide_left_prompt_item_separator_same_color ''
_set fake_tide_left_prompt_item_separator_diff_color ''
_set fake_tide_left_prompt_prefix ''
_set fake_tide_left_prompt_suffix ''
_set fake_tide_left_prompt_frame_enabled true
_set fake_tide_left_prompt_frame_color 6C6C6C
# ------------Right Prompt------------
_set fake_tide_right_prompt_items 'status' 'cmd_duration' 'context' 'jobs' 'virtual_env'
_set fake_tide_right_prompt_pad_items true
_set fake_tide_right_prompt_item_separator_same_color ''
_set fake_tide_right_prompt_item_separator_diff_color ''
_set fake_tide_right_prompt_prefix ''
_set fake_tide_right_prompt_suffix ''
_set fake_tide_right_prompt_frame_enabled true
_set fake_tide_right_prompt_frame_color 6C6C6C
# ---------Prompt Connection---------
_set fake_tide_prompt_connection_color 6C6C6C
_set fake_tide_prompt_connection_icon ' '
# --------------------Prompt Items--------------------
# ------------Prompt Char------------
_set fake_tide_prompt_char_success_color $_tide_color_green
_set fake_tide_prompt_char_failure_color FF0000
_set fake_tide_prompt_char_icon ''
_set fake_tide_prompt_char_bg_color normal
# ----------------Pwd----------------
_set fake_tide_pwd_truncate_margin 10
_set fake_tide_pwd_unwritable_icon '' # Lock
_set fake_tide_pwd_max_dirs 0
_set fake_tide_pwd_anchors 'first' 'last' 'git'
_set fake_tide_pwd_color_anchors $_tide_color_light_blue
_set fake_tide_pwd_color_dirs $_tide_color_dark_blue
_set fake_tide_pwd_color_truncated_dirs 8787AF
_set fake_tide_pwd_bg_color 444444
# ------------Git prompt------------
_set fake___fish_git_prompt_show_informative_status true
_set fake___fish_git_prompt_showstashstate true
_set fake_tide_git_prompt_bg_color 444444
# -------Symbols-------
_set fake___fish_git_prompt_char_stateseparator ''
_set fake___fish_git_prompt_char_cleanstate ''
_set fake___fish_git_prompt_char_upstream_ahead ' ⇡'
_set fake___fish_git_prompt_char_upstream_behind ' ⇣'
_set fake___fish_git_prompt_char_stagedstate ' +'
_set fake___fish_git_prompt_char_dirtystate ' !'
_set fake___fish_git_prompt_char_untrackedfiles ' ?'
_set fake___fish_git_prompt_char_stashstate ' *'
# --------Colors--------
_set fake___fish_git_prompt_color_branch $_tide_color_green
_set fake___fish_git_prompt_color_upstream $_tide_color_green
_set fake___fish_git_prompt_color_stagedstate $tideColorGold
_set fake___fish_git_prompt_color_dirtystate $tideColorGold
_set fake___fish_git_prompt_color_untrackedfiles $_tide_color_light_blue
_set fake___fish_git_prompt_color_stashstate $_tide_color_green
# --------------Status--------------
_set fake_tide_status_success_icon '✔'
_set fake_tide_status_success_color $tideColorDarkerGreen
_set fake_tide_status_failure_icon '✘'
_set fake_tide_status_failure_color D70000
_set fake_tide_status_bg_color 444444
# -----------Cmd_Duration-----------
_set fake_tide_cmd_duration_color 87875F
_set fake_tide_cmd_duration_decimals 0
_set fake_tide_cmd_duration_threshold 3000
_set fake_tide_cmd_duration_bg_color 444444
# --------------Context--------------
_set fake_tide_context_ssh_color D7AF87
_set fake_tide_context_root_color $tideColorGold
_set fake_tide_context_bg_color 444444
# ---------------Jobs---------------
_set fake_tide_jobs_icon '' # Gear
_set fake_tide_jobs_color $tideColorDarkerGreen
_set fake_tide_jobs_bg_color 444444
# ---------------Virtual_Env---------------
_set fake_tide_virtual_env_color 00AFAF
_set fake_tide_virtual_env_display 'projectName'
_set fake_tide_virtual_env_icon ''
_set fake_tide_virtual_env_bg_color 444444
# ---------------Time---------------
_set fake_tide_time_color 5F8787
_set fake_tide_time_format '%T'
_set fake_tide_time_bg_color 444444

View File

@ -9,13 +9,17 @@ _set fake_tide_left_prompt_prefix ''
_set fake_tide_left_prompt_items 'pwd' 'git_prompt' 'newline' 'prompt_char'
_set fake_tide_left_prompt_item_separator_same_color ' '
_set fake_tide_left_prompt_item_separator_diff_color ' '
_set fake_tide_left_prompt_pad_separators false
_set fake_tide_left_prompt_pad_items false
_set fake_tide_left_prompt_suffix ' '
_set fake_tide_left_prompt_frame_enabled false
# ------------Right Prompt------------
_set fake_tide_right_prompt_prefix ' '
_set fake_tide_right_prompt_items 'status' 'cmd_duration' 'context' 'jobs' 'virtual_env'
_set fake_tide_right_prompt_item_separator_same_color ' '
_set fake_tide_right_prompt_item_separator_diff_color ' '
_set fake_tide_right_prompt_pad_separators false
_set fake_tide_right_prompt_suffix ' '
_set fake_tide_right_prompt_pad_items false
_set fake_tide_right_prompt_suffix ''
_set fake_tide_right_prompt_frame_enabled false
# ---------Prompt Connection---------
_set fake_tide_prompt_connection_color 6C6C6C
_set fake_tide_prompt_connection_icon ' '

View File

@ -6,16 +6,20 @@ set -l tideColorDarkerGreen 5FAF00
_set fake_tide_print_newline_before_prompt 'true'
# ------------Left Prompt------------
_set fake_tide_left_prompt_prefix ''
_set fake_tide_left_prompt_items 'pwd' 'git_prompt' 'cmd_duration' 'newline' 'prompt_char'
_set fake_tide_left_prompt_items 'pwd' 'git_prompt' 'cmd_duration' 'newline' 'prompt_char' 'virtual_env'
_set fake_tide_left_prompt_item_separator_same_color ' '
_set fake_tide_left_prompt_item_separator_diff_color ' '
_set fake_tide_left_prompt_pad_separators false
_set fake_tide_left_prompt_pad_items false
_set fake_tide_left_prompt_suffix ' '
_set fake_tide_left_prompt_frame_enabled false
# ------------Right Prompt------------
_set fake_tide_right_prompt_prefix ' '
_set fake_tide_right_prompt_items
_set fake_tide_right_prompt_item_separator_same_color ' '
_set fake_tide_right_prompt_item_separator_diff_color ' '
_set fake_tide_right_prompt_pad_separators false
_set fake_tide_right_prompt_suffix ' '
_set fake_tide_right_prompt_pad_items false
_set fake_tide_right_prompt_suffix ''
_set fake_tide_right_prompt_frame_enabled false
# ---------Prompt Connection---------
_set fake_tide_prompt_connection_color 6C6C6C
_set fake_tide_prompt_connection_icon ' '

View File

@ -3,12 +3,11 @@ function fake_prompt
set -g _tide_last_status $status
set_color $fake_tide_prompt_connection_color
printf "%.s$fake_tide_prompt_connection_icon" (seq $fake_columns)
set_color normal
string repeat --no-newline --max $fake_columns $fake_tide_prompt_connection_icon
printf '%b' '\r'
_fake_tide_right_prompt
printf '%b' '\r'
set_color normal
_fake_tide_left_prompt
set_color normal
end

View File

@ -0,0 +1,4 @@
function _fake_tide_count_left_prompt_height -v fake_tide_left_prompt_items
set -l numberOfNewlines (count (string match -a 'newline' $fake_tide_left_prompt_items))
set -g _fake_tide_left_prompt_height (math 1+$numberOfNewlines)
end

View File

@ -1,8 +1,85 @@
function _fake_tide_left_prompt
for item in _fake_tide_item_{$fake_tide_left_prompt_items}
set -l itemOutput ($item)
printf '%b' "$itemOutput"
set lastItemWasNewline # Display prefix instead of separator before first item
set color normal
set currentHeight 1
set_color normal
for item in $fake_tide_left_prompt_items
if test "$item" = 'newline'
_print_frame
if not set -q lastItemWasNewline && not set -q lastItemWasPromptChar
set_color $previousColor -b normal
printf '%s' $fake_tide_left_prompt_suffix
end
printf '%b' '\n'
set lastItemWasNewline
set currentHeight (math $currentHeight +1)
continue
end
set -l output (_fake_tide_item_$item)
if test -n "$output"
_print_frame
set -l colorName fake_tide_"$item"_bg_color
set -l color $$colorName
if set -e lastItemWasNewline || set -e lastItemWasPromptChar
if test "$item" != 'prompt_char'
set_color $color -b normal
printf '%s' $fake_tide_left_prompt_prefix
end
else
if test "$color" = "$previousColor"
set_color $fake_tide_left_prompt_item_separator_same_color_color
printf '%s' $fake_tide_left_prompt_item_separator_same_color
else
set_color $previousColor -b $color
printf '%s' $fake_tide_left_prompt_item_separator_diff_color
end
end
set_color -b $color
if test "$fake_tide_left_prompt_pad_items" = 'true' -a "$item" != 'prompt_char'
printf '%s' " $output"(set_color -b $color)' ' # The set_color is for git_prompt which resets the background color
else
printf '%s' "$output"
end
set previousColor $color
if test "$item" = 'prompt_char'
set lastItemWasPromptChar
end
end
end
if set -q lastItemWasNewline
if test "$fake_tide_left_prompt_frame_enabled" = 'true'
set_color $fake_tide_left_prompt_frame_color
printf '%s' '╰─'
end
else if not set -q lastItemWasPromptChar
set_color $previousColor -b normal
printf '%s' $fake_tide_left_prompt_suffix
end
end
function _print_frame --no-scope-shadowing
if set -q lastItemWasNewline && test "$fake_tide_left_prompt_frame_enabled" = 'true'
set_color $fake_tide_left_prompt_frame_color -b normal
if test $currentHeight -eq 1
printf '%s' '╭─'
else if test $currentHeight -lt $_fake_tide_left_prompt_height
printf '%s' '├─'
else
printf '%s' '╰─'
end
end
end

View File

@ -1,30 +1,102 @@
function _fake_tide_right_prompt
set -l splitText (string split '\n' (_fetch_right_prompt_items))
set -l splitText (_fetch_right_prompt_items | string split '@NEWLINE@')
set -l printAtEndedRightPromptHeight (count $splitText)
for thing in $splitText
_print_at_end $thing
if test "$fake_tide_right_prompt_frame_enabled" = 'true'
# The right frame should always look exactly like the left frame would, regardless of how many lines splitText actually has.
# In this section we check if each line exist, if so add the frame to it. If not, insert a line containing only the frame
# and update printAtEndedRightPromptHeight
set -l frameColor (set_color $fake_tide_right_prompt_frame_color -b normal)
set splitText[1] $splitText[1]$frameColor'─╮'
if test $_fake_tide_left_prompt_height -gt 1
if test $printAtEndedRightPromptHeight -gt 1
set splitText[-1] $splitText[-1]$frameColor'─╯'
else
set splitText[2] $frameColor'─╯'
set printAtEndedRightPromptHeight (math $printAtEndedRightPromptHeight+1)
end
if test $_fake_tide_left_prompt_height -gt 2
if test $printAtEndedRightPromptHeight -gt 2
set splitText[2..-2] $splitText[2..-2]$frameColor'─┤'
else
set splitText $splitText[1] $frameColor'─┤' $splitText[2]
set printAtEndedRightPromptHeight (math $printAtEndedRightPromptHeight+1)
end
end
end
end
for lineOfText in $splitText
_print_at_end $lineOfText
end
_tide_cursor_up $printAtEndedRightPromptHeight
end
function _fetch_right_prompt_items
printf '%s' ' '
set lastItemWasNewline # Display prefix instead of separator before first item
set color normal
for item in _fake_tide_item_{$fake_tide_right_prompt_items}
set -l itemOutput ($item)
printf '%s' "$itemOutput"
set_color normal
set_color normal
for item in $fake_tide_right_prompt_items
if test "$item" = 'newline'
if not set -q lastItemWasNewline
set_color $previousColor -b normal
printf '%s' $fake_tide_right_prompt_suffix
end
printf '%b' '\n'
set lastItemWasNewline
continue
end
set -l output (_fake_tide_item_$item)
if test -n "$output"
set -l colorName fake_tide_"$item"_bg_color
set -l color $$colorName
if set -e lastItemWasNewline
set_color $color -b normal
printf '%s' $fake_tide_right_prompt_prefix
else
if test "$color" = "$previousColor"
set_color $fake_tide_right_prompt_item_separator_same_color_color
printf '%s' $fake_tide_right_prompt_item_separator_same_color
else
set_color $color -b $previousColor
printf '%s' $fake_tide_right_prompt_item_separator_diff_color
end
end
set_color -b $color
if test "$fake_tide_right_prompt_pad_items" = 'true'
printf '%s' ' '$output(set_color -b $color)' ' # The set_color is for git_prompt which resets the background color
else
printf '%s' "$output"
end
set previousColor $color
end
end
if not set -q lastItemWasNewline
set_color $previousColor -b normal
printf '%s' $fake_tide_right_prompt_suffix
end
end
function _print_at_end -a text
set -l startLocation (math $fake_columns -(string length (_tide_decolor $text)))
set -l startLocation (math $fake_columns -(_tide_decolor $text | string length))
_tide_cursor_right $startLocation
printf '%s' $text
printf '%b' '\v'
printf '%b' '\r'
printf '%s%b' $text '\v\r' # For some reason \n doesn't work but \v\r does
end

View File

@ -1,4 +1,4 @@
function _fake_tide_item_cmd_duration
set_color $fake_tide_cmd_duration_color
printf '%s ' '5s'
printf '%s' '5s'
end

View File

@ -1,4 +1,4 @@
function _fake_tide_item_git_prompt
set_color $fake___fish_git_prompt_color_branch
printf '%s ' 'master'
printf '%s' 'master'
end

View File

@ -1,3 +0,0 @@
function _fake_tide_item_newline
printf '%s' '\n'
end

View File

@ -2,17 +2,17 @@ function _fake_tide_item_pwd
if set -q fake_tide_pwd_anchors[1]
set_color -o $fake_tide_pwd_color_anchors
printf '%s' '~'
set_color normal
set_color normal -b $fake_tide_pwd_bg_color
set_color $fake_tide_pwd_color_dirs
printf '%s' '/'
set_color normal
set_color normal -b $fake_tide_pwd_bg_color
set_color -o $fake_tide_pwd_color_anchors
printf '%s ' 'src'
set_color normal
printf '%s' 'src'
set_color normal -b $fake_tide_pwd_bg_color
else
set_color $fake_tide_pwd_color_dirs
printf '%s ' '~/src'
printf '%s' '~/src'
end
end

View File

@ -1,4 +1,4 @@
function _fake_tide_item_time
set_color $fake_tide_time_color
printf '%s ' (date +$fake_tide_time_format)
printf '%s' (date +$fake_tide_time_format)
end