mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-21 11:39:57 +03:00
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.
This commit is contained in:
parent
736d6cf7e6
commit
7160027c14
@ -171,6 +171,8 @@ def test_fish_integration(self):
|
||||
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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user