From 4dc1e733a7fb6e85f41da87f5e4ca09e116a043c Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 6 Apr 2024 18:38:15 +0200 Subject: [PATCH 1/2] doc keyboard protocol: mention upcoming support in fish --- docs/keyboard-protocol.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/keyboard-protocol.rst b/docs/keyboard-protocol.rst index 14e96419e..066b79e92 100644 --- a/docs/keyboard-protocol.rst +++ b/docs/keyboard-protocol.rst @@ -52,6 +52,7 @@ In addition to kitty, this protocol is also implemented in: * The `yazi file manager `__ * The `awrit web browser `__ * The `nushell shell `__ +* The `fish shell `__ .. versionadded:: 0.20.0 From 8951581815202405153621df39e5d9abcbe0ce36 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 6 Apr 2024 22:35:14 +0200 Subject: [PATCH 2/2] fish integration: drop redundant OSC 133 markers in upcoming fish 3.8 The upcoming fish 3.8 release will output OSC 133 sequences unconditionally [1]. I tested ctrl-shift-{g,x,z} bindings both without and with kitty's shell integration on top; everything seems to work. Let's simplify kitty integration by removing the markers for the upcoming fish >= 3.8. I have hopes that the native OSC 133 implementation address #7200 though I'm not sure if I could reproduce this bug (I only saw a similar bug when `fish_handle_reflow` was not enabled, which fish also does now (same commit)). cc @iacore let me know if you can reproduce #7200 with latest fish master. [1]: https://github.com/fish-shell/fish-shell/commit/3b9e3e251bf9d4c7d0b31275cac55df68fe0127a --- docs/shell-integration.rst | 2 + .../kitty-shell-integration.fish | 41 +++++++++++-------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/docs/shell-integration.rst b/docs/shell-integration.rst index 812151143..a2e84726a 100644 --- a/docs/shell-integration.rst +++ b/docs/shell-integration.rst @@ -85,6 +85,8 @@ no-cwd no-prompt-mark Turn off marking of prompts. This disables jumping to prompt, browsing output of last command and click to move cursor functionality. + Note that for the fish shell this does not take effect, since fish always + marks prompts. no-complete Turn off completion for the kitty command. diff --git a/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish b/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish index a074d2639..005d5b296 100644 --- a/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish +++ b/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish @@ -71,27 +71,32 @@ function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after # Enable prompt marking with OSC 133 if not contains "no-prompt-mark" $_ksi and not set -q __ksi_prompt_state - function __ksi_mark_prompt_start --on-event fish_prompt --on-event fish_cancel --on-event fish_posterror - test "$__ksi_prompt_state" != prompt-start - and echo -en "\e]133;D\a" - set --global __ksi_prompt_state prompt-start - echo -en "\e]133;A;special_key=1\a" - end - __ksi_mark_prompt_start + # fish 3.8 emits prompt markers, so we don't need to. + # Cheesily detect that version by probing for another feature. + if not bind --function-names | string match -q forward-char-passive + function __ksi_mark_prompt_start --on-event fish_prompt --on-event fish_cancel --on-event fish_posterror + test "$__ksi_prompt_state" != prompt-start + and echo -en "\e]133;D\a" + set --global __ksi_prompt_state prompt-start + echo -en "\e]133;A;special_key=1\a" + end + __ksi_mark_prompt_start - function __ksi_mark_output_start --on-event fish_preexec - set --global __ksi_prompt_state pre-exec - echo -en "\e]133;C\a" + function __ksi_mark_output_start --on-event fish_preexec + set --global __ksi_prompt_state pre-exec + echo -en "\e]133;C\a" + end + + function __ksi_mark_output_end --on-event fish_postexec + set --global __ksi_prompt_state post-exec + echo -en "\e]133;D;$status\a" + end + + # With prompt marking, kitty clears the current prompt on resize, + # so we need fish to redraw it. + set --global fish_handle_reflow 1 end - function __ksi_mark_output_end --on-event fish_postexec - set --global __ksi_prompt_state post-exec - echo -en "\e]133;D;$status\a" - end - - # With prompt marking, kitty clears the current prompt on resize, - # so we need fish to redraw it. - set --global fish_handle_reflow 1 # Binding for special key to move cursor on mouse click without triggering any # autocompletion or other effects set --local suffix ''