From 274dff37dbb375821a90d6976a11cf57d9386e4f Mon Sep 17 00:00:00 2001 From: Stone Date: Tue, 30 Jul 2024 03:59:17 +0800 Subject: [PATCH] fix(fish): improve fish transient prompt (#6107) * feat(fish): improve fish transient prompt * feat(fish): improve fish transient prompt --- src/init/starship.fish | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/init/starship.fish b/src/init/starship.fish index 21e1f0ff..85c665b4 100644 --- a/src/init/starship.fish +++ b/src/init/starship.fish @@ -11,6 +11,7 @@ function fish_prompt set STARSHIP_DURATION "$CMD_DURATION$cmd_duration" set STARSHIP_JOBS (count (jobs -p)) if test "$TRANSIENT" = "1" + set -g TRANSIENT 0 # Clear from cursor to end of screen as `commandline -f repaint` does not do this # See https://github.com/fish-shell/fish-shell/issues/8418 printf \e\[0J @@ -36,7 +37,8 @@ function fish_right_prompt # Account for changes in variable name between v2.7 and v3.0 set STARSHIP_DURATION "$CMD_DURATION$cmd_duration" set STARSHIP_JOBS (count (jobs -p)) - if test "$TRANSIENT" = "1" + if test "$RIGHT_TRANSIENT" = "1" + set -g RIGHT_TRANSIENT 0 if type -q starship_transient_rprompt_func starship_transient_rprompt_func else @@ -58,14 +60,19 @@ set -gx STARSHIP_SHELL "fish" # Transience related functions function reset-transient --on-event fish_postexec set -g TRANSIENT 0 + set -g RIGHT_TRANSIENT 0 end function transient_execute - if commandline --is-valid + if commandline --paging-mode + commandline -f accept-autosuggestion + return + end + commandline --is-valid + if test $status != 2 set -g TRANSIENT 1 + set -g RIGHT_TRANSIENT 1 commandline -f repaint - else - set -g TRANSIENT 0 end commandline -f execute end