From 47b3c37bf05fec8cccf7f5a3a0e69ce1b352953b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 15 Mar 2022 20:25:39 +0530 Subject: [PATCH] Add cwd reporting to fish integration --- kitty_tests/shell_integration.py | 7 +++++++ .../fish/vendor_conf.d/kitty-shell-integration.fish | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/kitty_tests/shell_integration.py b/kitty_tests/shell_integration.py index 0f919b790..cd4e46e9e 100644 --- a/kitty_tests/shell_integration.py +++ b/kitty_tests/shell_integration.py @@ -171,6 +171,13 @@ 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') + self.assertTrue(pty.screen.last_reported_cwd.endswith(self.home_dir)) + q = os.path.join(self.home_dir, 'testing-cwd-notification-🐱') + os.mkdir(q) + pty.send_cmd_to_child(f'cd {q}') + pty.wait_till(lambda: pty.screen.last_reported_cwd.endswith(q)) + pty.send_cmd_to_child('cd -') + pty.wait_till(lambda: pty.screen.last_reported_cwd.endswith(self.home_dir)) # completion and prompt marking pty.send_cmd_to_child('clear') 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 e2ffc0e3f..6370d19d4 100644 --- a/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish +++ b/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish @@ -94,4 +94,12 @@ function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after # so we need fish to redraw it. set --global fish_handle_reflow 1 end + + # Enable CWD reporting + if not contains "no-cwd" $_ksi + function __ksi_report_cwd --on-variable PWD --description "Report PWD changes to the terminal" + echo -en "\e]7;kitty-shell-cwd://$hostname$PWD\a" + end + __ksi_report_cwd + end end