Add workaround for terminals confused by MSYS2 paths

Some terminals handle invalid OSC 7 working directories by falling
back to the home directory, which is worse than if they didn't support
OSC 7.  Try to work arond the common case (when $MSYSTEM is set).

	local wezterm = require 'wezterm'
	local config = wezterm.config_builder()
	config.default_prog = {
	     'C:\\msys64\\msys2_shell.cmd',
	    '-ucrt64',
	    '-defterm',
	    '-here',
	    '-no-start',
	    '-shell', 'fish'
	}
	config.default_cwd = 'C:\\msys64\\home\\xxx'
	return config

Upstream issues:
- https://github.com/wezterm/wezterm/discussions/7330
- https://invent.kde.org/utilities/konsole/-/merge_requests/1136

Closes #11981
This commit is contained in:
Johannes Altmanninger
2025-11-02 08:20:45 +01:00
parent ceec382161
commit 20e66ad990
2 changed files with 4 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ Interactive improvements
- :doc:`fish_config prompt {choose,save} <cmds/fish_config>` have been taught to reset :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` in addition to the other prompt functions (:issue:`11937`).
- Fish now hides the portion of a multiline prompt that is scrolled out of view due to a huge command line. This prevents duplicate lines after repainting with partially visible prompt (:issue:`11911`).
- On macOS, fish sets :envvar:`MANPATH` correctly also when that variable was already present in the environment (:issue:`10684`).
- Added a workaround for MSYS2 to prevent Konsole and WezTerm from opening new tabs in the wrong working directory (:issue:`11981`).
Scripting improvements
----------------------

View File

@@ -165,6 +165,9 @@ end" >$__fish_config_dir/config.fish
if set -q KONSOLE_VERSION
set host ''
end
if [ -n "$MSYSTEM" ] && string match -rq -- '^(Konsole|WezTerm) ' (status terminal)
return
end
if [ "$TERM" = dumb ]
return
end