tmux

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package tmux provides a Go-native tmux session client that creates sessions from declarative window definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client creates and manages tmux sessions from window definitions.

func New

func New(exec executil.Executor) *Client

New creates a Client with the given executor.

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

func (c *Client) AttachOrSwitch(ctx context.Context, name string) error

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

func (c *Client) HasSession(ctx context.Context, name string) bool

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 window before attaching.

type RenderedWindow

type RenderedWindow struct {
	Name    string // Window name
	Command string // Command to run (empty = default shell)
	Dir     string // Working directory (empty = session default)
	Focus   bool   // Select this window after creation
}

RenderedWindow is a fully-resolved tmux window definition (no templates).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL