ZSH integration: Report cwd on every new prompt draw

Handles the case of a command reporting a different cwd to the terminal.
This commit is contained in:
Kovid Goyal 2022-11-27 10:09:25 +05:30
parent c54a4021ef
commit d92f89e47f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -230,6 +230,10 @@ _ksi_deferred_init() {
if (( ! opt[(Ie)no-cwd] )); then if (( ! opt[(Ie)no-cwd] )); then
_ksi_report_pwd() { builtin print -nu $_ksi_fd '\e]7;kitty-shell-cwd://'"$HOST""$PWD"'\a'; } _ksi_report_pwd() { builtin print -nu $_ksi_fd '\e]7;kitty-shell-cwd://'"$HOST""$PWD"'\a'; }
chpwd_functions=(${chpwd_functions[@]} "_ksi_report_pwd") chpwd_functions=(${chpwd_functions[@]} "_ksi_report_pwd")
# An executed program could change cwd and report the changed cwd, so also report cwd at each new prompt
# as in this case chpwd_functions is insufficient. chpwd_functions is still needed for things like: cd x && something
functions[_ksi_precmd]+="
_ksi_report_pwd"
_ksi_report_pwd _ksi_report_pwd
fi fi