Fixed git_prompt bug, thank god

This commit is contained in:
Ilan Cosman 2020-05-16 21:43:27 -07:00
parent 305cc12f54
commit 1c286fc473
6 changed files with 24 additions and 13 deletions

View File

@ -0,0 +1,11 @@
function _cursor_up -a number
if test $number -gt 0
printf '\033['$number'A'
end
end
function _cursor_right -a number
if test $number -gt 0
printf '\033['$number'C'
end
end

View File

@ -1,6 +1,7 @@
function local_install -a localRepo function local_install -a localRepo
source "$localRepo/install.fish"; and _set_lean_defaults source "$localRepo/install.fish"; and _set_lean_defaults
cp -r "$localRepo/conf.d" $__fish_config_dir
cp -r "$localRepo/functions" $__fish_config_dir cp -r "$localRepo/functions" $__fish_config_dir
cp -r "$localRepo/lean_theme" $__fish_config_dir cp -r "$localRepo/lean_theme" $__fish_config_dir
cp -r "$localRepo/tests" $__fish_config_dir cp -r "$localRepo/tests" $__fish_config_dir

View File

@ -1,5 +0,0 @@
function _up -a number
if test $number -ne 0
echo -ne '\033['$number'A'
end
end

View File

@ -13,7 +13,6 @@ function fish_prompt --description 'Write out the prompt'
printf '\r' printf '\r'
lean_right_prompt lean_right_prompt
_up $lean_left_prompt_height
printf '\r' printf '\r'
lean_left_prompt lean_left_prompt

View File

@ -5,7 +5,7 @@ function lean_left_prompt
set -l itemOutput (_$item) set -l itemOutput (_$item)
if test -n "$itemOutput" if test -n "$itemOutput"
echo -ne $itemOutput printf $itemOutput
end end
if test $item = 'lean_newline' if test $item = 'lean_newline'
set -U lean_left_prompt_height (math $lean_left_prompt_height+1) set -U lean_left_prompt_height (math $lean_left_prompt_height+1)

View File

@ -1,19 +1,21 @@
function lean_right_prompt function lean_right_prompt
set -l splitText (string split '\n' (_fetch_right_prompt_items)) set -l splitText (string split '\n' (_fetch_right_prompt_items))
for thing in $splitText[1..-2] for thing in $splitText[1..-2]
_print_at_end $thing _print_at_end $thing
end end
if test (count $splitText) -eq $lean_left_prompt_height if test (count $splitText) -eq $lean_left_prompt_height
set -g fishRightPromptRun $splitText[-1] set -g lean_right_prompt_fish $splitText[-1]
else else
_print_at_end $splitText[-1] _print_at_end $splitText[-1]
set -g fishRightPromptRun '' set -g lean_right_prompt_fish ''
end end
echo
_cursor_up (math $lean_left_prompt_height-1)
end end
function fish_right_prompt function fish_right_prompt
echo $fishRightPromptRun echo $lean_right_prompt_fish
end end
function _fetch_right_prompt_items function _fetch_right_prompt_items
@ -32,6 +34,9 @@ end
function _print_at_end -a text function _print_at_end -a text
set -l startLocation (math $COLUMNS-(string length (lean_decolor $text))) set -l startLocation (math $COLUMNS-(string length (lean_decolor $text)))
echo -ne '\033['$startLocation'C' _cursor_right $startLocation
echo $text echo -n $text
printf '\v'
printf '\r'
end end