package main
import (
"fmt"
gotmux "github.com/jubnzv/go-tmux"
)
func main() {
// Create instance of the running tmux server.
server := new(gotmux.Server)
// Prepare a configuration for the new session that contains some windows.
session := gotmux.Session{Name: "windows-panes", StartDirectory: "/tmp/"}
w1 := gotmux.Window{Name: "first", Id: 0, StartDirectory: "/tmp/"}
w2 := gotmux.Window{Name: "second", Id: 1}
w2.AddPane(gotmux.Pane{
ID: 0,
})
w2.AddPane(gotmux.Pane{
ID: 1,
})
w2.AddPane(gotmux.Pane{
ID: 3,
})
session.AddWindow(w1)
session.AddWindow(w2)
server.AddSession(session)
sessions := []*gotmux.Session{}
sessions = append(sessions, &session)
conf := gotmux.Configuration{
Server: server,
Sessions: sessions,
ActiveSession: nil,
}
// Setup this configuration.
err := conf.Apply()
if err != nil {
msg := fmt.Errorf("Can't apply prepared configuration: %s", err)
fmt.Println(msg)
return
}
currentWindows, _ := session.ListWindows()
for _, w := range currentWindows {
fmt.Printf("Current window: %v\n", w)
currentPanes, _ := w.ListPanes()
fmt.Printf("Current panes: %v\n", currentPanes)
}
// Attach to the created session
err = session.AttachSession()
if err != nil {
msg := fmt.Errorf("Can't attached to created session: %s", err)
fmt.Println(msg)
return
}
}
Current window: {first 29 0 windows-panes /private/tmp []}
Current panes: [{45 12 windows-panes 29 first 0 true} {46 12 windows-panes 30 second 1 false} {47 12 windows-panes 30 second 1 false} {48 12 windows-panes 30 second 1 true}]
Current window: {second 30 0 windows-panes /go-tmux []}
Current panes: [{45 12 windows-panes 29 first 0 true} {46 12 windows-panes 30 second 1 false} {47 12 windows-panes 30 second 1 false} {48 12 windows-panes 30 second 1 true}]
I would expect, that only Panes of the specific window should be returned.