2020-11-21 01:04:04 +03:00
|
|
|
function _tide_prompt
|
2020-12-26 03:54:24 +03:00
|
|
|
# Variables are exported as strings, convert _tide_last_pipestatus back into a list
|
|
|
|
set -g _tide_last_pipestatus (string split ' ' $_tide_last_pipestatus)
|
2020-12-26 19:42:21 +03:00
|
|
|
|
2021-05-04 21:03:38 +03:00
|
|
|
test "$tide_prompt_add_newline_before" = true && echo
|
2020-11-21 01:04:04 +03:00
|
|
|
|
2021-05-05 06:26:58 +03:00
|
|
|
leftPrompt=(_tide_left_prompt) rightPrompt=(_tide_right_prompt) if set -q leftPrompt[2] # If the prompt is two lines
|
2021-05-05 01:17:19 +03:00
|
|
|
set -l promptAndFrameColor (set_color $tide_prompt_frame_and_connection_color -b normal || echo)
|
|
|
|
|
2021-03-04 22:05:49 +03:00
|
|
|
if test "$tide_left_prompt_frame_enabled" = true
|
2021-05-05 01:17:19 +03:00
|
|
|
set leftPrompt[1] $promptAndFrameColor╭─"$leftPrompt[1]"
|
|
|
|
set leftPrompt[2] $promptAndFrameColor╰─"$leftPrompt[2]"
|
2021-03-04 22:05:49 +03:00
|
|
|
end
|
|
|
|
if test "$tide_right_prompt_frame_enabled" = true
|
2021-05-05 01:17:19 +03:00
|
|
|
set rightPrompt[1] "$rightPrompt[1]"$promptAndFrameColor─╮
|
|
|
|
set rightPrompt[2] "$rightPrompt[2]"$promptAndFrameColor─╯
|
2021-03-04 22:05:49 +03:00
|
|
|
end
|
|
|
|
|
2021-05-05 01:17:19 +03:00
|
|
|
printf '%s' $leftPrompt[1] $promptAndFrameColor
|
2021-03-04 22:05:49 +03:00
|
|
|
|
2021-03-10 22:41:24 +03:00
|
|
|
set -l lengthToMove (math $COLUMNS - (_tide_decolor "$leftPrompt[1]""$rightPrompt[1]" | string length))
|
|
|
|
test $lengthToMove -gt 0 && string repeat --no-newline --max $lengthToMove $tide_prompt_connection_icon
|
2021-03-04 22:05:49 +03:00
|
|
|
|
2021-05-05 01:25:38 +03:00
|
|
|
printf '%s' $rightPrompt[1] \n $leftPrompt[-1]' '
|
|
|
|
set -U $_tide_right_prompt_display_var $rightPrompt[2]
|
|
|
|
else
|
|
|
|
printf '%s' $leftPrompt[-1]' '
|
|
|
|
set -U $_tide_right_prompt_display_var $rightPrompt[1]
|
2021-03-04 22:05:49 +03:00
|
|
|
end
|
2021-01-01 07:14:55 +03:00
|
|
|
end
|
2021-05-04 19:29:34 +03:00
|
|
|
|
|
|
|
function _tide_left_prompt
|
2021-05-08 23:08:36 +03:00
|
|
|
set -g _tide_last_item newline
|
2021-05-04 19:29:34 +03:00
|
|
|
set -g _tide_which_side_working_on left
|
|
|
|
|
|
|
|
for item in $tide_left_prompt_items
|
|
|
|
_tide_item_$item
|
|
|
|
end
|
|
|
|
|
2021-05-08 23:08:36 +03:00
|
|
|
if not contains -- $_tide_last_item newline character
|
|
|
|
set_color $_tide_previous_bg_color -b normal
|
2021-05-04 19:29:34 +03:00
|
|
|
printf '%s' $tide_left_prompt_suffix
|
|
|
|
end
|
|
|
|
|
|
|
|
set_color normal # Make sure there is something printed on the last line
|
|
|
|
end
|
|
|
|
|
|
|
|
function _tide_right_prompt
|
2021-05-08 23:08:36 +03:00
|
|
|
set -g _tide_last_item newline
|
2021-05-04 19:29:34 +03:00
|
|
|
set -g _tide_which_side_working_on right
|
|
|
|
|
|
|
|
for item in $tide_right_prompt_items
|
|
|
|
_tide_item_$item
|
|
|
|
end
|
|
|
|
|
2021-05-08 23:08:36 +03:00
|
|
|
if test "$_tide_last_item" != newline
|
|
|
|
set_color $_tide_previous_bg_color -b normal
|
2021-05-04 19:29:34 +03:00
|
|
|
printf '%s' $tide_right_prompt_suffix
|
|
|
|
end
|
|
|
|
|
|
|
|
set_color normal # Make sure there is something printed on the last line
|
|
|
|
end
|