Emit OSC 133 sequences to mark prompt/command output regions

This allows terminals like foot and kitty to
* scroll to the previous/next prompt with ctrl-shift-{z,x}
* pipe the last command's output to a pager with ctrl-shift-g

Kitty has existing fish shell integration
shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish which we
can simplify now. They keep a state variable to decide which of prompt start,
command start or command end to output.  I think with our implementation
this is no longer necessary, at least I couldn't reproduce any difference.
We also don't need to hook into fish_cancel or fish_posterror like they do;
only in the one place where we actually draw the prompt.

As mentioned in the above shell integration script, kitty disables reflow
when it sees an OSC 133 marker, so we need to do it ourselves,
otherwise the prompt will go blank after a terminal resize.

Closes #10352
This commit is contained in:
Johannes Altmanninger
2024-04-06 21:34:38 +02:00
parent 33701faa8c
commit 3b9e3e251b
5 changed files with 19 additions and 2 deletions

View File

@@ -200,7 +200,6 @@ end" >$__fish_config_dir/config.fish
if set -q VTE_VERSION
# Same for these terminals
or string match -q -- 'alacritty*' $TERM
or string match -q -- '*kitty' $TERM
or test "$TERM_PROGRAM" = WezTerm
set -g fish_handle_reflow 0
else if set -q KONSOLE_VERSION