From c8f1118e1470809ff9d8e1378328fc2f945c25e7 Mon Sep 17 00:00:00 2001 From: Johnny Chadda Date: Mon, 4 May 2026 15:08:23 +0200 Subject: [PATCH] fix: open zellij tabs in worktree dir on zellij 0.44+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Zellij 0.44 stopped honoring `new-tab --cwd ` when no INITIAL_COMMAND is supplied — the default shell starts in $HOME regardless. Pass $SHELL (with /bin/sh fallback) as the initial command so --cwd takes effect, plus --close-on-exit so the pane behaves like a normal default-shell tab (closes on exit instead of respawning). --- internal/zellij/zellij.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/zellij/zellij.go b/internal/zellij/zellij.go index 1ecdee3..d885c1e 100644 --- a/internal/zellij/zellij.go +++ b/internal/zellij/zellij.go @@ -44,8 +44,16 @@ func OpenTab(dir, repoName, worktreeName string) error { } } - // Tab doesn't exist, create it - create := exec.Command("zellij", "action", "new-tab", "--name", name, "--cwd", dir) + // Tab doesn't exist, create it. + // As of zellij 0.44, `new-tab --cwd` is only honored when an INITIAL_COMMAND is + // supplied — without one the default shell starts in $HOME. Pass $SHELL + // explicitly so --cwd takes effect, and --close-on-exit so the pane behaves + // like a normal shell tab (closes on exit instead of respawning). + shell := os.Getenv("SHELL") + if shell == "" { + shell = "/bin/sh" + } + create := exec.Command("zellij", "action", "new-tab", "--name", name, "--cwd", dir, "--close-on-exit", "--", shell) if err := create.Run(); err != nil { return fmt.Errorf("failed to create zellij tab %q: %w", name, err) }