diff options
Diffstat (limited to 'src/init/starship.fish')
-rw-r--r-- | src/init/starship.fish | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/src/init/starship.fish b/src/init/starship.fish index 569968eba..b427ec243 100644 --- a/src/init/starship.fish +++ b/src/init/starship.fish @@ -10,7 +10,18 @@ function fish_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)) - ::STARSHIP:: prompt --terminal-width="$COLUMNS" --status=$STARSHIP_CMD_STATUS --pipestatus="$STARSHIP_CMD_PIPESTATUS" --keymap=$STARSHIP_KEYMAP --cmd-duration=$STARSHIP_DURATION --jobs=$STARSHIP_JOBS + if test "$TRANSIENT" = "1" + # 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 + if type -q starship_transient_prompt_func + starship_transient_prompt_func + else + printf "\e[1;32m❯\e[0m " + end + else + ::STARSHIP:: prompt --terminal-width="$COLUMNS" --status=$STARSHIP_CMD_STATUS --pipestatus="$STARSHIP_CMD_PIPESTATUS" --keymap=$STARSHIP_KEYMAP --cmd-duration=$STARSHIP_DURATION --jobs=$STARSHIP_JOBS + end end function fish_right_prompt @@ -25,7 +36,15 @@ 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)) - ::STARSHIP:: prompt --right --terminal-width="$COLUMNS" --status=$STARSHIP_CMD_STATUS --pipestatus="$STARSHIP_CMD_PIPESTATUS" --keymap=$STARSHIP_KEYMAP --cmd-duration=$STARSHIP_DURATION --jobs=$STARSHIP_JOBS + if test "$TRANSIENT" = "1" + if type -q starship_transient_rprompt_func + starship_transient_rprompt_func + else + printf "" + end + else + ::STARSHIP:: prompt --right --terminal-width="$COLUMNS" --status=$STARSHIP_CMD_STATUS --pipestatus="$STARSHIP_CMD_PIPESTATUS" --keymap=$STARSHIP_KEYMAP --cmd-duration=$STARSHIP_DURATION --jobs=$STARSHIP_JOBS + end end # Disable virtualenv prompt, it breaks starship @@ -36,6 +55,29 @@ builtin functions -e fish_mode_prompt set -gx STARSHIP_SHELL "fish" +# Transience related functions +function reset-transient --on-event fish_postexec + set -g TRANSIENT 0 +end + +function transient_execute + if commandline --is-valid + set -g TRANSIENT 1 + commandline -f repaint + else + set -g TRANSIENT 0 + end + commandline -f execute +end + +function enable_transience + bind \r transient_execute +end + +function disable_transience + bind \r execute +end + # Set up the session key that will be used to store logs # We don't use `random [min] [max]` because it is unavailable in older versions of fish shell set -gx STARSHIP_SESSION_KEY (string sub -s1 -l16 (random)(random)(random)(random)(random)0000000000000000) |