|
30 | 30 | ---@return sidekick.cli.terminal.Cmd? |
31 | 31 | function M:start() |
32 | 32 | 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 } |
34 | 37 | vim.list_extend(cmd, { "-c", self.cwd }) |
35 | 38 | 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 |
38 | 52 | return { cmd = cmd } |
39 | 53 | elseif Config.cli.mux.create == "window" then |
40 | 54 | local cmd = { "tmux", "new-window", "-dP", "-c", self.cwd, "-F", PANE_FORMAT } |
|
0 commit comments