Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CWD notifications in kitty #8806

Merged
merged 1 commit into from
Mar 17, 2022
Merged

Conversation

page-down
Copy link
Contributor

Description

For upcoming SSH integration related features, kitty started to support parsing the current working directory from OSC 7.

In addition to the file:// escaped URL format, it also supports kitty-shell-cwd://$hostname$PWD, which does not require URL escaping.

https://github.com/kovidgoyal/kitty/blob/a834f221f1e289fc9da47a3c8eb97e013537e413/kitty/utils.py#L941-L947

To allow fish 3.2.0+ to report CWD as well, the following code was added to kitty's shell integration. Please feel free to point out if there is anything wrong with it.

https://github.com/kovidgoyal/kitty/blob/7160027c14437f4f387ee1a310024ce139199976/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish#L98-L108

# Enable CWD reporting
if not contains "no-cwd" $_ksi
    # 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
    __update_cwd_osc
end

Are we allowed to add kitty cwd format? Maybe that would improve performance.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

@faho
Copy link
Member

faho commented Mar 17, 2022

Are we allowed to add kitty cwd format? Maybe that would improve performance.

CWD reporting isn't a slowdown, at all.

string escape --style=url $PWD takes ~20 microseconds on my system. So no, I see no reason to add the special kitty version.

I will however merge the ordinary version. Thanks!

@faho faho merged commit 47294f4 into fish-shell:master Mar 17, 2022
@faho faho added this to the fish 3.5.0 milestone Mar 17, 2022
@page-down page-down deleted the kitty-cwd branch March 18, 2022 03:36
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants