From 4ff9f5184c92e1107324c2717d20d5429d29f588 Mon Sep 17 00:00:00 2001 From: mgajewskik Date: Tue, 10 Mar 2026 11:41:47 +0100 Subject: [PATCH] fix: tmux worktree shell environment loading --- src/plugin/worktree/terminal.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugin/worktree/terminal.ts b/src/plugin/worktree/terminal.ts index 4a7373d..d49fa93 100644 --- a/src/plugin/worktree/terminal.ts +++ b/src/plugin/worktree/terminal.ts @@ -257,9 +257,18 @@ export async function openTmuxWindow(options: { const escapedCwd = escapeBash(cwd) const escapedCommand = escapeBash(command) const scriptContent = wrapWithSelfCleanup( - `cd "${escapedCwd}" || exit 1 + `shell_path="\${SHELL:-/bin/bash}" +shell_name="\${shell_path##*/}" + +if [ "$shell_name" = "bash" ] || [ "$shell_name" = "zsh" ]; then + exec "$shell_path" -lic "cd \"${escapedCwd}\" || exit 1 +${escapedCommand} +exec \"$shell_path\" -li" +fi + +cd "${escapedCwd}" || exit 1 ${escapedCommand} -exec $SHELL`, +exec "$shell_path"`, ) await Bun.write(scriptPath, scriptContent) Bun.spawnSync(["chmod", "+x", scriptPath])