Send OSC 7 on fresh prompt (child may have changed it)

After I run a child process like "fish -C 'cd /tmp'", the terminal
will have a stale working directory.

Let's send the OSC 7 notification also once for every fresh prompt
(which is less frequent than the calls to fish_prompt).

This is not fully correct, since it will not work for cases like bind
ctrl-g 'fish -C "cd /tmp"' which allow running external commands
without creating a fresh prompt. We can fix those later, using the
code paths for bracketed paste and friends.
A minor argument for not fixing this just yet is that some people
override "__fish_update_cwd_osc" to work around bugs in their terminal.

Closes #12191
Closes #11778
Closes #11777
This commit is contained in:
Johannes Altmanninger
2025-12-19 15:56:02 +01:00
parent 5545c648d9
commit 3ec603fc55

View File

@@ -141,7 +141,8 @@ end" >$__fish_config_dir/config.fish
# Notify terminals when $PWD changes via OSC 7 (issue #906).
if not functions --query __fish_update_cwd_osc
function __fish_update_cwd_osc --on-variable PWD --description 'Notify terminals when $PWD changes'
function __fish_update_cwd_osc --description 'Notify terminals when $PWD might have changed' \
--on-variable=PWD --on-event=fish_prompt
set -l host $hostname
# if set -l konsole_version (string match -r -- '^Konsole (\d+)\..*' (status terminal))[2]
# # To-do: use a Konsole version where KF6_DEP_VERSION is >= 6.12