Compare commits

...
1 Commits
Author SHA1 Message Date
stefankoelle 9e6acdedc2 Fix Windows: use cmd.exe /c for tmux command chain
psmux on Windows doesn't handle ; separators when args are passed
individually via exec.Command. On Windows, build the full tmux
command string and run it through cmd.exe /c instead.
2026-08-09 21:27:37 +02:00
+23 -3
View File
@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
"runtime"
"sort" "sort"
tea "github.com/charmbracelet/bubbletea" tea "github.com/charmbracelet/bubbletea"
@@ -286,6 +287,25 @@ func (m *fullModel) startTmuxSession() tea.Cmd {
fmt.Fprintf(os.Stderr, "[debug] panelCmd=%s\n", panelCmd) fmt.Fprintf(os.Stderr, "[debug] panelCmd=%s\n", panelCmd)
fmt.Fprintf(os.Stderr, "[debug] kill-session err=%v\n", killErr) fmt.Fprintf(os.Stderr, "[debug] kill-session err=%v\n", killErr)
var c *exec.Cmd
if runtime.GOOS == "windows" {
// On Windows, psmux doesn't handle ; separators when args are
// passed individually via exec.Command. Build the full command
// string and run it through cmd.exe.
tmuxScript := fmt.Sprintf(
"tmux new-session -d -s kctl %q ; set-option -t kctl remain-on-exit on ; split-window -v -t kctl:0.0 %q",
panelCmd, k9sCmdA,
)
if len(m.cfg.Envs) > 1 {
envB := m.cfg.Envs[1]
ctxB := m.cfg.ResolveContext(envB, m.selectedContext)
k9sCmdB := fmt.Sprintf("k9s --context %s -n %s", ctxB, m.selectedNamespace)
tmuxScript += fmt.Sprintf(" ; split-window -v -t kctl:0.1 %q", k9sCmdB)
}
tmuxScript += " ; select-layout -t kctl even-vertical ; select-pane -t kctl:0.0 ; attach -t kctl"
fmt.Fprintf(os.Stderr, "[debug] windows cmd: %s\n", tmuxScript)
c = exec.Command("cmd.exe", "/c", tmuxScript)
} else {
args := []string{ args := []string{
"new-session", "-d", "-s", "kctl", "new-session", "-d", "-s", "kctl",
panelCmd, ";", panelCmd, ";",
@@ -305,9 +325,9 @@ func (m *fullModel) startTmuxSession() tea.Cmd {
"select-pane", "-t", "kctl:0.0", ";", "select-pane", "-t", "kctl:0.0", ";",
"attach", "-t", "kctl", "attach", "-t", "kctl",
) )
fmt.Fprintf(os.Stderr, "[debug] unix args: %v\n", args)
fmt.Fprintf(os.Stderr, "[debug] tmux args: %v\n", args) c = exec.Command("tmux", args...)
c := exec.Command("tmux", args...) }
return tea.ExecProcess(c, func(err error) tea.Msg { return tea.ExecProcess(c, func(err error) tea.Msg {
return tmuxDoneMsg{err: err} return tmuxDoneMsg{err: err}