From 7160027c14437f4f387ee1a310024ce139199976 Mon Sep 17 00:00:00 2001 From: pagedown Date: Wed, 16 Mar 2022 01:03:26 +0800 Subject: [PATCH] Use the fish built-in function name to report current working directory If the feature is enabled by fish in the future, it will override the built-in one and there will be no duplicate reporting. --- kitty_tests/shell_integration.py | 2 ++ .../fish/vendor_conf.d/kitty-shell-integration.fish | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/kitty_tests/shell_integration.py b/kitty_tests/shell_integration.py index f24020c7d..54fcb85f8 100644 --- a/kitty_tests/shell_integration.py +++ b/kitty_tests/shell_integration.py @@ -171,6 +171,8 @@ function _set_status_prompt; function fish_prompt; echo -n "$pipestatus $status pty.send_cmd_to_child('set -q XDG_DATA_DIRS; or echo ok') pty.wait_till(lambda: pty.screen_contents().count(right_prompt) == 2) self.ae(str(pty.screen.line(1)), 'ok') + + # CWD reporting self.assertTrue(pty.screen.last_reported_cwd.endswith(self.home_dir)) q = os.path.join(self.home_dir, 'testing-cwd-notification-🐱') os.mkdir(q) 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 47ddca061..05a1c928e 100644 --- a/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish +++ b/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish @@ -97,12 +97,13 @@ function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after # Enable CWD reporting if not contains "no-cwd" $_ksi - # This is actually builtin to fish but stupidly gated on TERM - # https://github.com/fish-shell/fish-shell/blob/master/share/functions/__fish_config_interactive.fish#L257 - function __ksi_report_cwd --on-variable PWD --description "Report PWD changes to the terminal" - status --is-command-substitution; and return - echo -en "\e]7;kitty-shell-cwd://$hostname$PWD\a" + # This function name is from fish and will override the builtin one if fish enabled this feature by default. + # We provide this to ensure that fish 3.2.0 and above will work. + # https://github.com/fish-shell/fish-shell/blob/3.2.0/share/functions/__fish_config_interactive.fish#L275 + function __update_cwd_osc --on-variable PWD -d "Report PWD changes to kitty" + status is-command-substitution + or echo -en "\e]7;kitty-shell-cwd://$hostname$PWD\a" end - __ksi_report_cwd + __update_cwd_osc end end