tide/functions/tide_right_prompt.fish

41 lines
1.1 KiB
Fish
Raw Normal View History

2020-05-19 06:03:25 +03:00
function tide_right_prompt
2020-05-15 07:53:37 +03:00
set -l splitText (string split '\n' (_fetch_right_prompt_items))
2020-05-18 19:44:33 +03:00
set -l printAtEndedRightPromptHeight (count $splitText)
2020-05-17 07:43:27 +03:00
2020-05-15 07:53:37 +03:00
for thing in $splitText[1..-2]
_print_at_end $thing
end
2020-05-19 06:03:25 +03:00
if test $printAtEndedRightPromptHeight -eq $tide_left_prompt_height
set -g tide_right_prompt_fish $splitText[-1]
2020-05-18 19:44:33 +03:00
set printAtEndedRightPromptHeight (math $printAtEndedRightPromptHeight-1)
2020-05-15 07:53:37 +03:00
else
_print_at_end $splitText[-1]
2020-05-19 06:03:25 +03:00
set -g tide_right_prompt_fish ''
2020-05-15 07:53:37 +03:00
end
2020-05-17 07:43:27 +03:00
2020-05-18 19:44:33 +03:00
_cursor_up $printAtEndedRightPromptHeight
2020-05-15 07:53:37 +03:00
end
function fish_right_prompt
2020-05-19 06:03:25 +03:00
printf '%s' $tide_right_prompt_fish
2020-05-15 07:53:37 +03:00
end
function _fetch_right_prompt_items
2020-05-18 20:06:02 +03:00
printf '%s' ' '
2020-05-19 06:03:25 +03:00
for item in tide_{$tide_right_prompt_items}
2020-05-09 01:32:58 +03:00
set -l itemOutput (_$item)
2020-05-18 20:06:02 +03:00
printf '%s' "$itemOutput"
2020-05-09 01:32:58 +03:00
set_color normal
end
2020-05-15 07:53:37 +03:00
end
function _print_at_end -a text
2020-05-19 06:03:25 +03:00
set -l startLocation (math $COLUMNS -(string length (tide_decolor $text)))
2020-05-18 19:44:33 +03:00
_cursor_right $startLocation
2020-05-18 20:06:02 +03:00
printf '%s' $text
2020-05-17 07:43:27 +03:00
2020-05-18 20:06:02 +03:00
printf '%b' '\v'
printf '%b' '\r'
2020-04-21 21:52:24 +03:00
end