This commit is contained in:
Ilan Cosman 2021-09-08 10:54:31 -07:00
parent 04b37f45a4
commit e2f594cde1
11 changed files with 52 additions and 53 deletions

View File

@ -12,7 +12,7 @@ function _tide_init_install --on-event _tide_init_install
case y ye yes '' case y ye yes ''
tide configure tide configure
case '*' case '*'
printf '%s' \n 'Run ' (printf '%s' "tide configure" | fish_indent --ansi) ' to customize your prompt.' \n echo -ns \n 'Run ' (echo -ns "tide configure" | fish_indent --ansi) ' to customize your prompt.' \n
end end
end end

View File

@ -1,16 +1,16 @@
function _tide_detect_os function _tide_detect_os
switch (uname | string lower) switch (uname | string lower)
case darwin case darwin
printf '%s' echo -ns
case freebsd openbsd dragonfly case freebsd openbsd dragonfly
printf '%s' echo -ns
case linux case linux
_tide_detect_os_linux_cases /etc/os-release ID || _tide_detect_os_linux_cases /etc/os-release ID ||
_tide_detect_os_linux_cases /etc/os-release ID_LIKE || _tide_detect_os_linux_cases /etc/os-release ID_LIKE ||
_tide_detect_os_linux_cases /etc/lsb-release DISTRIB_ID || _tide_detect_os_linux_cases /etc/lsb-release DISTRIB_ID ||
printf '%s' echo -ns
case '*' case '*'
printf '%s' '?' echo -ns '?'
end end
end end
@ -43,5 +43,5 @@ function _tide_detect_os_linux_cases -a file key
ubuntu ubuntu
set -l distro_index (contains --index $value $distro_icons) || return set -l distro_index (contains --index $value $distro_icons) || return
printf '%s' $distro_icons[(math $distro_index + 1)] echo -ns $distro_icons[(math $distro_index + 1)]
end end

View File

@ -6,17 +6,17 @@ function _tide_item_character
end end
if test "$fish_key_bindings" = fish_default_key_bindings if test "$fish_key_bindings" = fish_default_key_bindings
printf %s $tide_character_icon echo -ns $tide_character_icon
else else
switch $fish_bind_mode switch $fish_bind_mode
case insert case insert
printf %s $tide_character_icon echo -ns $tide_character_icon
case default case default
printf %s $tide_character_vi_icon_default echo -ns $tide_character_vi_icon_default
case replace replace_one case replace replace_one
printf %s $tide_character_vi_icon_replace echo -ns $tide_character_vi_icon_replace
case visual case visual
printf %s $tide_character_vi_icon_visual echo -ns $tide_character_vi_icon_visual
end end
end end
end end

View File

@ -60,12 +60,12 @@ function _tide_item_git
set -g tide_git_bg_color $tide_git_bg_color_unstable set -g tide_git_bg_color $tide_git_bg_color_unstable
end end
_tide_print_item git $_tide_location_color $tide_git_icon' ' (set_color white; printf %s $location _tide_print_item git $_tide_location_color $tide_git_icon' ' (set_color white; echo -ns $location
set_color $tide_git_color_operation; printf %s ' '$tide_git_operation ' '$tide_git_step/$tide_git_total_steps set_color $tide_git_color_operation; echo -ns ' '$tide_git_operation ' '$tide_git_step/$tide_git_total_steps
set_color $tide_git_color_upstream; printf %s ' ⇣'$upstream_behind ' ⇡'$upstream_ahead set_color $tide_git_color_upstream; echo -ns ' ⇣'$upstream_behind ' ⇡'$upstream_ahead
set_color $tide_git_color_stash; printf %s ' *'$stash set_color $tide_git_color_stash; echo -ns ' *'$stash
set_color $tide_git_color_conflicted; printf %s ' ~'$conflicted set_color $tide_git_color_conflicted; echo -ns ' ~'$conflicted
set_color $tide_git_color_staged; printf %s ' +'$staged set_color $tide_git_color_staged; echo -ns ' +'$staged
set_color $tide_git_color_dirty; printf %s ' !'$dirty set_color $tide_git_color_dirty; echo -ns ' !'$dirty
set_color $tide_git_color_untracked; printf %s ' ?'$untracked) set_color $tide_git_color_untracked; echo -ns ' ?'$untracked)
end end

View File

@ -1,5 +1,5 @@
function _tide_item_newline function _tide_item_newline
set_color $_tide_previous_bg_color -b normal set_color $_tide_previous_bg_color -b normal
side_working_on_suffix_name=tide_"$_tide_which_side_working_on"_prompt_suffix printf '%s' $$side_working_on_suffix_name \n side_working_on_suffix_name=tide_"$_tide_which_side_working_on"_prompt_suffix echo $$side_working_on_suffix_name
set -g _tide_last_item_was_newline set -g _tide_last_item_was_newline
end end

View File

@ -4,31 +4,31 @@ function _tide_print_item -a item
if test "$_tide_which_side_working_on" = left if test "$_tide_which_side_working_on" = left
if set -e _tide_last_item_was_newline if set -e _tide_last_item_was_newline
set_color $item_bg_color -b normal set_color $item_bg_color -b normal
printf '%s' $tide_left_prompt_prefix echo -ns $tide_left_prompt_prefix
else if test "$item_bg_color" = "$_tide_previous_bg_color" else if test "$item_bg_color" = "$_tide_previous_bg_color"
set_color $tide_prompt_color_separator_same_color set_color $tide_prompt_color_separator_same_color
printf '%s' $tide_left_prompt_separator_same_color echo -ns $tide_left_prompt_separator_same_color
else else
set_color $_tide_previous_bg_color -b $item_bg_color set_color $_tide_previous_bg_color -b $item_bg_color
printf '%s' $tide_left_prompt_separator_diff_color echo -ns $tide_left_prompt_separator_diff_color
end end
else if set -e _tide_last_item_was_newline else if set -e _tide_last_item_was_newline
set_color $item_bg_color -b normal set_color $item_bg_color -b normal
printf '%s' $tide_right_prompt_prefix echo -ns $tide_right_prompt_prefix
else if test "$item_bg_color" = "$_tide_previous_bg_color" else if test "$item_bg_color" = "$_tide_previous_bg_color"
set_color $tide_prompt_color_separator_same_color set_color $tide_prompt_color_separator_same_color
printf '%s' $tide_right_prompt_separator_same_color echo -ns $tide_right_prompt_separator_same_color
else else
set_color $item_bg_color -b $_tide_previous_bg_color set_color $item_bg_color -b $_tide_previous_bg_color
printf '%s' $tide_right_prompt_separator_diff_color echo -ns $tide_right_prompt_separator_diff_color
end end
item_color_name=tide_"$item"_color set_color $$item_color_name -b $item_bg_color item_color_name=tide_"$item"_color set_color $$item_color_name -b $item_bg_color
if test "$tide_prompt_pad_items" = true if test "$tide_prompt_pad_items" = true
printf '%s' ' ' $argv[2..] ' ' echo -ns ' ' $argv[2..] ' '
else else
printf '%s' $argv[2..] echo -ns $argv[2..]
end end
set -g _tide_previous_bg_color $item_bg_color set -g _tide_previous_bg_color $item_bg_color

View File

@ -13,10 +13,10 @@ function _tide_prompt
# 5 = @PWD@ length which will be replaced # 5 = @PWD@ length which will be replaced
math $COLUMNS+5-(string length --visible "$left_prompt[1]""$right_prompt[1]") | read -lx dist_btwn_sides math $COLUMNS+5-(string length --visible "$left_prompt[1]""$right_prompt[1]") | read -lx dist_btwn_sides
printf '%s' (string replace @PWD@ (_tide_pwd) "$left_prompt[1]") $_tide_prompt_and_frame_color echo -ns (string replace @PWD@ (_tide_pwd) "$left_prompt[1]") $_tide_prompt_and_frame_color
string repeat --no-newline --max (math max 0, $dist_btwn_sides-$pwd_length) $tide_prompt_icon_connection string repeat --no-newline --max (math max 0, $dist_btwn_sides-$pwd_length) $tide_prompt_icon_connection
printf '%s' $right_prompt[1] \n $left_prompt[2]' ' echo -ns $right_prompt[1] \n $left_prompt[2]' '
else else
echo $right_prompt[1] echo $right_prompt[1]
@ -34,7 +34,7 @@ function _tide_left_prompt
if not set -e _tide_last_item_was_newline if not set -e _tide_last_item_was_newline
set_color $_tide_previous_bg_color -b normal set_color $_tide_previous_bg_color -b normal
printf '%s' $tide_left_prompt_suffix echo -ns $tide_left_prompt_suffix
end end
set_color normal # Make sure there is something printed on the last line set_color normal # Make sure there is something printed on the last line
@ -49,7 +49,7 @@ function _tide_right_prompt
if not set -e _tide_last_item_was_newline if not set -e _tide_last_item_was_newline
set_color $_tide_previous_bg_color -b normal set_color $_tide_previous_bg_color -b normal
printf '%s' $tide_right_prompt_suffix echo -ns $tide_right_prompt_suffix
end end
set_color normal # Make sure there is something printed on the last line set_color normal # Make sure there is something printed on the last line

View File

@ -16,7 +16,7 @@ end
function _tide_sub_configure function _tide_sub_configure
if test $COLUMNS -lt 55 -o $LINES -lt 21 if test $COLUMNS -lt 55 -o $LINES -lt 21
printf '%s\n' 'Terminal size too small; must be at least 55 x 21' echo 'Terminal size too small; must be at least 55 x 21'
return 1 return 1
end end
@ -45,16 +45,15 @@ function _tide_option -a symbol text
set -ga _tide_option_list $symbol set -ga _tide_option_list $symbol
set_color -o set_color -o
printf '%s\n' "($symbol) $text" echo "($symbol) $text"
set_color normal set_color normal
end end
function _tide_menu function _tide_menu
set -l list_with_slashes (string join '/' $_tide_option_list) set -l list_with_slashes (string join '/' $_tide_option_list)
printf '%s\n' \ echo '(r) Restart from the beginning'
'(r) Restart from the beginning' \ echo '(q) Quit and do nothing'\n
'(q) Quit and do nothing'\n
while true while true
set_color -o set_color -o

View File

@ -1,5 +1,5 @@
function _fake_tide_item_newline function _fake_tide_item_newline
set_color $_fake_tide_previous_bg_color -b normal set_color $_fake_tide_previous_bg_color -b normal
side_working_on_suffix_name=fake_tide_"$_fake_tide_which_side_working_on"_prompt_suffix printf '%s' $$side_working_on_suffix_name \n side_working_on_suffix_name=fake_tide_"$_fake_tide_which_side_working_on"_prompt_suffix echo -ns $$side_working_on_suffix_name \n
set -g _fake_tide_last_item newline set -g _fake_tide_last_item newline
end end

View File

@ -5,32 +5,32 @@ function _fake_tide_print_item -a item
if test "$_fake_tide_last_item" = newline if test "$_fake_tide_last_item" = newline
if test "$item" != character if test "$item" != character
set_color $item_bg_color -b normal set_color $item_bg_color -b normal
printf '%s' $fake_tide_left_prompt_prefix echo -ns $fake_tide_left_prompt_prefix
end end
else if test "$item_bg_color" = "$_fake_tide_previous_bg_color" else if test "$item_bg_color" = "$_fake_tide_previous_bg_color"
set_color $fake_tide_prompt_color_separator_same_color set_color $fake_tide_prompt_color_separator_same_color
printf '%s' $fake_tide_left_prompt_separator_same_color echo -ns $fake_tide_left_prompt_separator_same_color
else else
set_color $_fake_tide_previous_bg_color -b $item_bg_color set_color $_fake_tide_previous_bg_color -b $item_bg_color
printf '%s' $fake_tide_left_prompt_separator_diff_color echo -ns $fake_tide_left_prompt_separator_diff_color
end end
else if test "$_fake_tide_last_item" = newline else if test "$_fake_tide_last_item" = newline
set_color $item_bg_color -b normal set_color $item_bg_color -b normal
printf '%s' $fake_tide_right_prompt_prefix echo -ns $fake_tide_right_prompt_prefix
else if test "$item_bg_color" = "$_fake_tide_previous_bg_color" else if test "$item_bg_color" = "$_fake_tide_previous_bg_color"
set_color $fake_tide_prompt_color_separator_same_color set_color $fake_tide_prompt_color_separator_same_color
printf '%s' $fake_tide_right_prompt_separator_same_color echo -ns $fake_tide_right_prompt_separator_same_color
else else
set_color $item_bg_color -b $_fake_tide_previous_bg_color set_color $item_bg_color -b $_fake_tide_previous_bg_color
printf '%s' $fake_tide_right_prompt_separator_diff_color echo -ns $fake_tide_right_prompt_separator_diff_color
end end
item_color_name=fake_tide_"$item"_color set_color $$item_color_name -b $item_bg_color item_color_name=fake_tide_"$item"_color set_color $$item_color_name -b $item_bg_color
if test "$fake_tide_prompt_pad_items" = true -a "$item" != character if test "$fake_tide_prompt_pad_items" = true -a "$item" != character
printf '%s' ' ' $argv[2..] ' ' echo -ns ' ' $argv[2..] ' '
else else
printf '%s' $argv[2..] echo -ns $argv[2..]
end end
set -g _fake_tide_previous_bg_color $item_bg_color set -g _fake_tide_previous_bg_color $item_bg_color

View File

@ -11,23 +11,23 @@ function _fake_tide_prompt
set right_prompt[2] "$right_prompt[2]"$_tide_prompt_and_frame_color─╯ set right_prompt[2] "$right_prompt[2]"$_tide_prompt_and_frame_color─╯
end end
printf '%s' $left_prompt[1] $_tide_prompt_and_frame_color echo -ns $left_prompt[1] $_tide_prompt_and_frame_color
set -l dist_btwn_sides (math $fake_columns - ( # Regex removes color codes set -l dist_btwn_sides (math $fake_columns - ( # Regex removes color codes
string replace -ar '\e(\[[\d;]*|\(B\e\[)m(\co)?' '' "$left_prompt[1]""$right_prompt[1]" | string length)) string replace -ar '\e(\[[\d;]*|\(B\e\[)m(\co)?' '' "$left_prompt[1]""$right_prompt[1]" | string length))
test $dist_btwn_sides -gt 0 && string repeat --no-newline --max $dist_btwn_sides $fake_tide_prompt_icon_connection test $dist_btwn_sides -gt 0 && string repeat --no-newline --max $dist_btwn_sides $fake_tide_prompt_icon_connection
printf '%s' $right_prompt[1] \n $left_prompt[-1]' ' echo -ns $right_prompt[1] \n $left_prompt[-1]' '
string repeat --no-newline --max (math $fake_columns - ( # The -1 is necessary for some reason string repeat --no-newline --max (math $fake_columns - ( # The -1 is necessary for some reason
string replace -ar '\e(\[[\d;]*|\(B\e\[)m(\co)?' '' "$left_prompt[-1]""$right_prompt[-1]" | string length) - 1) ' ' string replace -ar '\e(\[[\d;]*|\(B\e\[)m(\co)?' '' "$left_prompt[-1]""$right_prompt[-1]" | string length) - 1) ' '
printf '%s' $right_prompt[2] echo -ns $right_prompt[2]
else else
printf '%s' $left_prompt[-1]' ' echo -ns $left_prompt[-1]' '
string repeat --no-newline --max (math $fake_columns - ( # The -1 is necessary for some reason string repeat --no-newline --max (math $fake_columns - ( # The -1 is necessary for some reason
string replace -ar '\e(\[[\d;]*|\(B\e\[)m(\co)?' '' "$left_prompt[-1]""$right_prompt[-1]" | string length) - 1) ' ' string replace -ar '\e(\[[\d;]*|\(B\e\[)m(\co)?' '' "$left_prompt[-1]""$right_prompt[-1]" | string length) - 1) ' '
printf '%s' $right_prompt[-1] echo -ns $right_prompt[-1]
end end
set_color normal set_color normal
@ -43,7 +43,7 @@ function _fake_tide_left_prompt
if not contains -- $_fake_tide_last_item newline character if not contains -- $_fake_tide_last_item newline character
set_color $_fake_tide_previous_bg_color -b normal set_color $_fake_tide_previous_bg_color -b normal
printf '%s' $fake_tide_left_prompt_suffix echo -ns $fake_tide_left_prompt_suffix
end end
set_color normal # Make sure there is something printed on the last line set_color normal # Make sure there is something printed on the last line
@ -59,7 +59,7 @@ function _fake_tide_right_prompt
if test "$_fake_tide_last_item" != newline if test "$_fake_tide_last_item" != newline
set_color $_fake_tide_previous_bg_color -b normal set_color $_fake_tide_previous_bg_color -b normal
printf '%s' $fake_tide_right_prompt_suffix echo -ns $fake_tide_right_prompt_suffix
end end
set_color normal # Make sure there is something printed on the last line set_color normal # Make sure there is something printed on the last line