Skip to content

Commit 7c20424

Browse files
authored
Merge pull request #2 from john-mutuma/fix/windows-tmux-set-option
fix(tmux): run set-option as separate commands on Windows for psmux compatibility
2 parents 46b0a18 + 0a5ad1e commit 7c20424

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

lua/sidekick/cli/session/tmux.lua

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,25 @@ end
3030
---@return sidekick.cli.terminal.Cmd?
3131
function M:start()
3232
if not self.external then
33-
local cmd = { "tmux", "new", "-A", "-s", self.id }
33+
-- Sanitize session name: replace spaces with hyphens for psmux/Windows compatibility
34+
local session_name = self.id:gsub("%s+", "-")
35+
self.mux_session = session_name
36+
local cmd = { "tmux", "new", "-A", "-s", session_name }
3437
vim.list_extend(cmd, { "-c", self.cwd })
3538
self:add_cmd(cmd)
36-
vim.list_extend(cmd, { ";", "set-option", "status", "off" })
37-
vim.list_extend(cmd, { ";", "set-option", "detach-on-destroy", "on" })
39+
if vim.fn.has("win32") == 1 then
40+
-- On Windows (psmux), ";" command chaining is not supported.
41+
-- PowerShell interprets ";" as a statement separator, causing
42+
-- "set-option" to be run as a standalone cmdlet (which fails).
43+
-- Instead, run set-option as separate commands after the session starts.
44+
vim.defer_fn(function()
45+
vim.fn.system({ "tmux", "set-option", "-t", session_name, "status", "off" })
46+
vim.fn.system({ "tmux", "set-option", "-t", session_name, "detach-on-destroy", "on" })
47+
end, 1000)
48+
else
49+
vim.list_extend(cmd, { ";", "set-option", "status", "off" })
50+
vim.list_extend(cmd, { ";", "set-option", "detach-on-destroy", "on" })
51+
end
3852
return { cmd = cmd }
3953
elseif Config.cli.mux.create == "window" then
4054
local cmd = { "tmux", "new-window", "-dP", "-c", self.cwd, "-F", PANE_FORMAT }

0 commit comments

Comments
 (0)