Session Control
SendText, GetBuffer, Inject, Activate, Close, Restart — complete session lifecycle.
A developer-friendly Go library that mirrors the official iTerm2 Python API. Control sessions, split panes, capture screenshots, subscribe to events — all via WebSocket.
Features
Full coverage of the iTerm2 Python API — sessions, panes, variables, events, and more.
SendText, GetBuffer, Inject, Activate, Close, Restart — complete session lifecycle.
SplitPane (vertical/horizontal), CreateTab, traverse nested splitter trees.
GetVariable, SetVariable, GetProperty, SetProperty, SetProfileProperty.
Capture Window, Tab, or Session as PNG via native macOS screencapture.
Subscribe to new sessions, keystrokes, focus changes, variable changes.
Register custom RPCs, handle server-originated requests, extend iTerm2.
API Preview
Connect, traverse the window hierarchy, and send text — all in a few lines.
package main import "github.com/phpgao/term2go" func main() { // Connect to iTerm2 — auto-detects cookie/key term2go.Run(ctx, "my-app", func(caller term2go.Caller) error { app, _ := term2go.GetApp(caller) // Traverse window → tab → session hierarchy for _, w := range app.Windows { for _, t := range w.Tabs { // Send a command to each session sess := t.Root.FindSessionByID("session-id") sess.SendText(ctx, "echo Hello term2go!\n", false) } } return nil }) }
Control your terminal from Go. Star the repo, browse the examples, and start hacking.