From 1c286fc473e7f1ddfb1ab57b5c4bbfdefa53463b Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Sat, 16 May 2020 21:43:27 -0700 Subject: [PATCH] Fixed git_prompt bug, thank god --- conf.d/lean_cursor_movement.fish | 11 +++++++++++ dev/local_install.fish | 1 + functions/_up.fish | 5 ----- functions/fish_prompt.fish | 1 - functions/lean_left_prompt.fish | 2 +- functions/lean_right_prompt.fish | 17 +++++++++++------ 6 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 conf.d/lean_cursor_movement.fish delete mode 100644 functions/_up.fish diff --git a/conf.d/lean_cursor_movement.fish b/conf.d/lean_cursor_movement.fish new file mode 100644 index 0000000..bd240a4 --- /dev/null +++ b/conf.d/lean_cursor_movement.fish @@ -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 \ No newline at end of file diff --git a/dev/local_install.fish b/dev/local_install.fish index 74283c2..6ec494e 100644 --- a/dev/local_install.fish +++ b/dev/local_install.fish @@ -1,6 +1,7 @@ function local_install -a localRepo 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/lean_theme" $__fish_config_dir cp -r "$localRepo/tests" $__fish_config_dir diff --git a/functions/_up.fish b/functions/_up.fish deleted file mode 100644 index 0a1de18..0000000 --- a/functions/_up.fish +++ /dev/null @@ -1,5 +0,0 @@ -function _up -a number - if test $number -ne 0 - echo -ne '\033['$number'A' - end -end \ No newline at end of file diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index cc84737..e2e2e82 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -13,7 +13,6 @@ function fish_prompt --description 'Write out the prompt' printf '\r' lean_right_prompt - _up $lean_left_prompt_height printf '\r' lean_left_prompt diff --git a/functions/lean_left_prompt.fish b/functions/lean_left_prompt.fish index f84d386..b8a9a8a 100644 --- a/functions/lean_left_prompt.fish +++ b/functions/lean_left_prompt.fish @@ -5,7 +5,7 @@ function lean_left_prompt set -l itemOutput (_$item) if test -n "$itemOutput" - echo -ne $itemOutput + printf $itemOutput end if test $item = 'lean_newline' set -U lean_left_prompt_height (math $lean_left_prompt_height+1) diff --git a/functions/lean_right_prompt.fish b/functions/lean_right_prompt.fish index 6ebcdd3..343a30b 100644 --- a/functions/lean_right_prompt.fish +++ b/functions/lean_right_prompt.fish @@ -1,19 +1,21 @@ function lean_right_prompt set -l splitText (string split '\n' (_fetch_right_prompt_items)) + for thing in $splitText[1..-2] _print_at_end $thing end if test (count $splitText) -eq $lean_left_prompt_height - set -g fishRightPromptRun $splitText[-1] + set -g lean_right_prompt_fish $splitText[-1] else _print_at_end $splitText[-1] - set -g fishRightPromptRun '' + set -g lean_right_prompt_fish '' end - echo + + _cursor_up (math $lean_left_prompt_height-1) end function fish_right_prompt - echo $fishRightPromptRun + echo $lean_right_prompt_fish end function _fetch_right_prompt_items @@ -32,6 +34,9 @@ end function _print_at_end -a text set -l startLocation (math $COLUMNS-(string length (lean_decolor $text))) - echo -ne '\033['$startLocation'C' - echo $text + _cursor_right $startLocation + echo -n $text + + printf '\v' + printf '\r' end \ No newline at end of file