fix: added option to auto select pane

This commit is contained in:
raj 2023-10-23 00:53:32 +05:30
parent d3d90ddb05
commit cdeaed61f7
2 changed files with 11 additions and 0 deletions

View File

@ -30,6 +30,7 @@ type Configuration struct {
LastOpened time.Time LastOpened time.Time
Attach bool `yaml:"attach"` Attach bool `yaml:"attach"`
StartupWindow string `yaml:"startup_window"` StartupWindow string `yaml:"startup_window"`
StartupPane int `yaml:"startup_pane"`
} }
var configDir string var configDir string

View File

@ -109,6 +109,16 @@ func CreateTmuxSession(config *projectconfig.Configuration) error {
} }
log.Debug("Ran command", "command", selectWindowCmd.String()) 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 { if config.Attach {
switchSessionCmd := exec.Command("tmux", "switch-client", "-t", sessionName) switchSessionCmd := exec.Command("tmux", "switch-client", "-t", sessionName)
if err := switchSessionCmd.Run(); err != nil { if err := switchSessionCmd.Run(); err != nil {