From cdeaed61f76a90138e649dfaf561650cee605ce9 Mon Sep 17 00:00:00 2001 From: raj Date: Mon, 23 Oct 2023 00:53:32 +0530 Subject: [PATCH] fix: added option to auto select pane --- config/main.go | 1 + controller/tmux.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/config/main.go b/config/main.go index 415bf8e..432e1d0 100644 --- a/config/main.go +++ b/config/main.go @@ -30,6 +30,7 @@ type Configuration struct { LastOpened time.Time Attach bool `yaml:"attach"` StartupWindow string `yaml:"startup_window"` + StartupPane int `yaml:"startup_pane"` } var configDir string diff --git a/controller/tmux.go b/controller/tmux.go index 79c68af..4a53284 100644 --- a/controller/tmux.go +++ b/controller/tmux.go @@ -109,6 +109,16 @@ func CreateTmuxSession(config *projectconfig.Configuration) error { } log.Debug("Ran command", "command", selectWindowCmd.String()) + // Select initial pane + if config.StartupPane > 0 { + defaultPane := fmt.Sprintf("%s:%d.%d", sessionName, config.StartupPane, 1) + selectPaneCmd := exec.Command("tmux", "select-pane", "-t", defaultPane) + if err := selectPaneCmd.Run(); err != nil { + return err + } + log.Debug("Ran command", "command", selectPaneCmd.String()) + } + if config.Attach { switchSessionCmd := exec.Command("tmux", "switch-client", "-t", sessionName) if err := switchSessionCmd.Run(); err != nil {