1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-12-04 19:03:38 +00:00

fix(fish): improve fish transient prompt (#6107)

* feat(fish): improve fish transient prompt

* feat(fish): improve fish transient prompt
This commit is contained in:
Stone 2024-07-30 03:59:17 +08:00 committed by GitHub
parent e629ea1c7a
commit 274dff37db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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