mirror of
https://github.com/IlanCosman/tide.git
synced 2024-11-26 09:42:51 +03:00
Use two prompts
This commit is contained in:
parent
8dde77e9f6
commit
20f85e4e11
23
functions/_tide_1_line_prompt.fish
Normal file
23
functions/_tide_1_line_prompt.fish
Normal file
@ -0,0 +1,23 @@
|
||||
function _tide_1_line_prompt
|
||||
set -g add_prefix
|
||||
_tide_side=left set -f left (for item in $_tide_left_items
|
||||
_tide_item_$item
|
||||
end
|
||||
set_color $prev_bg_color -b normal
|
||||
echo -ns $tide_left_prompt_suffix)
|
||||
|
||||
set -g add_prefix
|
||||
_tide_side=right set -f right (for item in $_tide_right_items
|
||||
_tide_item_$item
|
||||
end
|
||||
set_color $prev_bg_color -b normal
|
||||
echo -ns $tide_right_prompt_suffix)
|
||||
|
||||
# 5 = @PWD@ length which will be replaced
|
||||
math $COLUMNS+5-(string length --visible "$left[1]$right[1]") -$tide_prompt_min_cols | read -lx dist_btwn_sides
|
||||
string replace @PWD@ (_tide_pwd) "$right[1]" "$left[1] "
|
||||
end
|
||||
|
||||
function _tide_item_pwd
|
||||
_tide_print_item pwd @PWD@
|
||||
end
|
43
functions/_tide_2_line_prompt.fish
Normal file
43
functions/_tide_2_line_prompt.fish
Normal file
@ -0,0 +1,43 @@
|
||||
function _tide_2_line_prompt
|
||||
set -g add_prefix
|
||||
_tide_side=left set -f left (for item in $_tide_left_items
|
||||
_tide_item_$item
|
||||
end
|
||||
if not set -e add_prefix
|
||||
set_color $prev_bg_color -b normal
|
||||
echo -ns $tide_left_prompt_suffix
|
||||
end)
|
||||
|
||||
set -g add_prefix
|
||||
_tide_side=right set -f right (for item in $_tide_right_items
|
||||
_tide_item_$item
|
||||
end
|
||||
if not set -e add_prefix
|
||||
set_color $prev_bg_color -b normal
|
||||
echo -ns $tide_right_prompt_suffix
|
||||
end)
|
||||
|
||||
test "$tide_left_prompt_frame_enabled" = true &&
|
||||
set left[1] "$_tide_prompt_and_frame_color╭─$left[1]" &&
|
||||
set left[2] "$_tide_prompt_and_frame_color╰─$left[2]"
|
||||
test "$tide_right_prompt_frame_enabled" = true &&
|
||||
set right[1] "$right[1]$_tide_prompt_and_frame_color─╮" &&
|
||||
set right[2] "$right[2]$_tide_prompt_and_frame_color─╯"
|
||||
|
||||
# 5 = @PWD@ length which will be replaced
|
||||
math $COLUMNS+5-(string length --visible "$left[1]$right[1]") | read -lx dist_btwn_sides
|
||||
echo -ns "$right[2]"\n(string replace @PWD@ (_tide_pwd) "$left[1]")$_tide_prompt_and_frame_color
|
||||
|
||||
string repeat --no-newline --max (math max 0, $dist_btwn_sides-$pwd_length) $tide_prompt_icon_connection
|
||||
echo -ns "$right[1]"\n"$left[2] "
|
||||
end
|
||||
|
||||
function _tide_item_pwd
|
||||
_tide_print_item pwd @PWD@
|
||||
end
|
||||
|
||||
function _tide_item_newline
|
||||
set_color $prev_bg_color -b normal
|
||||
var=tide_"$_tide_side"_prompt_suffix echo $$var
|
||||
set -g add_prefix
|
||||
end
|
@ -36,8 +36,10 @@ function _tide_cache_variables
|
||||
# two line prompt
|
||||
if contains newline $_tide_left_items
|
||||
set_color $tide_prompt_color_frame_and_connection -b normal | read -gx _tide_prompt_and_frame_color
|
||||
set -g _tide_prompt_num_lines _tide_2_line_prompt
|
||||
else
|
||||
set -e _tide_prompt_and_frame_color
|
||||
set -g _tide_prompt_num_lines _tide_1_line_prompt
|
||||
end
|
||||
|
||||
# newline before
|
||||
|
@ -1,5 +0,0 @@
|
||||
function _tide_item_newline
|
||||
set_color $prev_bg_color -b normal
|
||||
var=tide_"$_tide_side"_prompt_suffix echo $$var
|
||||
set -g add_prefix
|
||||
end
|
@ -1,42 +0,0 @@
|
||||
function _tide_prompt
|
||||
set -g add_prefix
|
||||
_tide_side=left set -f left (for item in $_tide_left_items
|
||||
_tide_item_$item
|
||||
end
|
||||
if not set -e add_prefix
|
||||
set_color $prev_bg_color -b normal
|
||||
echo -ns $tide_left_prompt_suffix
|
||||
end)
|
||||
|
||||
set -g add_prefix
|
||||
_tide_side=right set -f right (for item in $_tide_right_items
|
||||
_tide_item_$item
|
||||
end
|
||||
if not set -e add_prefix
|
||||
set_color $prev_bg_color -b normal
|
||||
echo -ns $tide_right_prompt_suffix
|
||||
end)
|
||||
|
||||
if set -q _tide_prompt_and_frame_color # If prompt is two lines
|
||||
test "$tide_left_prompt_frame_enabled" = true &&
|
||||
set left[1] "$_tide_prompt_and_frame_color╭─$left[1]" &&
|
||||
set left[2] "$_tide_prompt_and_frame_color╰─$left[2]"
|
||||
test "$tide_right_prompt_frame_enabled" = true &&
|
||||
set right[1] "$right[1]$_tide_prompt_and_frame_color─╮" &&
|
||||
set right[2] "$right[2]$_tide_prompt_and_frame_color─╯"
|
||||
|
||||
# 5 = @PWD@ length which will be replaced
|
||||
math $COLUMNS+5-(string length --visible "$left[1]$right[1]") | read -lx dist_btwn_sides
|
||||
echo -ns "$right[2]"\n(string replace @PWD@ (_tide_pwd) "$left[1]")$_tide_prompt_and_frame_color
|
||||
|
||||
string repeat --no-newline --max (math max 0, $dist_btwn_sides-$pwd_length) $tide_prompt_icon_connection
|
||||
echo -ns "$right[1]"\n"$left[2] "
|
||||
else
|
||||
math $COLUMNS+5-(string length --visible "$left[1]$right[1]") -$tide_prompt_min_cols | read -lx dist_btwn_sides
|
||||
string replace @PWD@ (_tide_pwd) "$right[1]" "$left[1] "
|
||||
end
|
||||
end
|
||||
|
||||
function _tide_item_pwd
|
||||
_tide_print_item pwd @PWD@
|
||||
end
|
@ -21,7 +21,7 @@ var="function fish_prompt
|
||||
jobs --query
|
||||
fish --command \"set _tide_pipestatus \$_tide_pipestatus
|
||||
_tide_jobs_status=\$status CMD_DURATION=\$CMD_DURATION COLUMNS=\$COLUMNS \
|
||||
fish_bind_mode=\$fish_bind_mode set $_tide_prompt_var (_tide_prompt)\" &
|
||||
fish_bind_mode=\$fish_bind_mode set $_tide_prompt_var ($_tide_prompt_num_lines)\" &
|
||||
builtin disown
|
||||
|
||||
command kill \$_tide_last_pid 2>/dev/null
|
||||
@ -30,7 +30,7 @@ var="function fish_prompt
|
||||
|
||||
string unescape $_tide_add_newline \$\$_tide_prompt_var[1][2..]
|
||||
end" eval "$var"
|
||||
set -e _tide_add_newline
|
||||
set -e _tide_add_newline _tide_prompt_num_lines
|
||||
|
||||
function fish_right_prompt
|
||||
string unescape $$_tide_prompt_var[1][1]
|
||||
|
Loading…
Reference in New Issue
Block a user