From 0a5ad1e5b8ac7b98316401460db7acc9a1204a42 Mon Sep 17 00:00:00 2001 From: "John Mutuma (from Dev Box)" Date: Sun, 1 Mar 2026 12:57:12 +0300 Subject: [PATCH] fix(tmux): run set-option as separate commands on Windows for psmux compatibility --- lua/sidekick/cli/session/tmux.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lua/sidekick/cli/session/tmux.lua b/lua/sidekick/cli/session/tmux.lua index 942ed7d..bbaa164 100644 --- a/lua/sidekick/cli/session/tmux.lua +++ b/lua/sidekick/cli/session/tmux.lua @@ -30,11 +30,25 @@ end ---@return sidekick.cli.terminal.Cmd? function M:start() if not self.external then - local cmd = { "tmux", "new", "-A", "-s", self.id } + -- Sanitize session name: replace spaces with hyphens for psmux/Windows compatibility + local session_name = self.id:gsub("%s+", "-") + self.mux_session = session_name + local cmd = { "tmux", "new", "-A", "-s", session_name } vim.list_extend(cmd, { "-c", self.cwd }) self:add_cmd(cmd) - vim.list_extend(cmd, { ";", "set-option", "status", "off" }) - vim.list_extend(cmd, { ";", "set-option", "detach-on-destroy", "on" }) + if vim.fn.has("win32") == 1 then + -- On Windows (psmux), ";" command chaining is not supported. + -- PowerShell interprets ";" as a statement separator, causing + -- "set-option" to be run as a standalone cmdlet (which fails). + -- Instead, run set-option as separate commands after the session starts. + vim.defer_fn(function() + vim.fn.system({ "tmux", "set-option", "-t", session_name, "status", "off" }) + vim.fn.system({ "tmux", "set-option", "-t", session_name, "detach-on-destroy", "on" }) + end, 1000) + else + vim.list_extend(cmd, { ";", "set-option", "status", "off" }) + vim.list_extend(cmd, { ";", "set-option", "detach-on-destroy", "on" }) + end return { cmd = cmd } elseif Config.cli.mux.create == "window" then local cmd = { "tmux", "new-window", "-dP", "-c", self.cwd, "-F", PANE_FORMAT }