Documentation
¶
Overview ¶
Package tmux provides a Go-native tmux session client that creates sessions from declarative window definitions.
Index ¶
- func DetectCurrentTmuxSession() string
- type Client
- func (c *Client) AddWindows(ctx context.Context, name, workDir string, windows []RenderedWindow) error
- func (c *Client) AttachOrSwitch(ctx context.Context, name string) error
- func (c *Client) CreateSession(ctx context.Context, name, workDir string, windows []RenderedWindow, ...) error
- func (c *Client) HasSession(ctx context.Context, name string) bool
- func (c *Client) OpenSession(ctx context.Context, name, workDir string, windows []RenderedWindow, ...) error
- type RenderedPane
- type RenderedWindow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectCurrentTmuxSession ¶ added in v0.41.0
func DetectCurrentTmuxSession() string
DetectCurrentTmuxSession returns the current tmux session name, or empty if not in tmux.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client creates and manages tmux sessions from window definitions.
func (*Client) AddWindows ¶
func (c *Client) AddWindows(ctx context.Context, name, workDir string, windows []RenderedWindow) error
AddWindows adds windows to an existing tmux session. If any window has Focus set, that window is selected after all windows are created.
func (*Client) AttachOrSwitch ¶
AttachOrSwitch connects to an existing tmux session. Inside tmux it uses switch-client; outside it uses attach-session.
func (*Client) CreateSession ¶
func (c *Client) CreateSession(ctx context.Context, name, workDir string, windows []RenderedWindow, background bool) error
CreateSession creates a tmux session with the given windows. The first window is created via new-session; additional windows via new-window. If background is true, the session is created detached.
func (*Client) HasSession ¶
HasSession checks whether a tmux session with the given name exists.
func (*Client) OpenSession ¶
func (c *Client) OpenSession(ctx context.Context, name, workDir string, windows []RenderedWindow, background bool, targetWindow string) error
OpenSession creates a session if it doesn't exist, or attaches to it. If targetWindow is non-empty and the session already exists, select that legacy tmux target (window or pane).
type RenderedPane ¶ added in v0.52.0
type RenderedPane struct {
Command string // Command to run (empty = default shell)
Dir string // Working directory (empty = window/session default)
Size string // Pane size passed to tmux -l (empty = tmux default)
Split string // Split direction: horizontal or vertical (default vertical)
}
RenderedPane is a fully-resolved tmux pane definition (no templates).
type RenderedWindow ¶
type RenderedWindow struct {
Name string // Window name
Command string // Command to run (empty = default shell); ignored when Panes is non-empty
Dir string // Working directory (empty = session default)
Focus bool // Select this window after creation
Panes []RenderedPane // Panes to create in this window; mutually exclusive with Command
}
RenderedWindow is a fully-resolved tmux window definition (no templates).