From 20e66ad990ac03da79081be259467e55d0b0cbc3 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 2 Nov 2025 08:20:45 +0100 Subject: [PATCH] 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 --- CHANGELOG.rst | 1 + share/functions/__fish_config_interactive.fish | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index abb6345dd..8f542847a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -19,6 +19,7 @@ Interactive improvements - :doc:`fish_config prompt {choose,save} ` have been taught to reset :doc:`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 ---------------------- diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index 7c421820e..eaa3aa5a1 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -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