Help us shape the future of Go! Take the 2026 Go Developer Survey

tmuxexec

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package tmuxexec implements the tmux terminal multiplexer adapter.

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 implements tmux operations over a Runner.

func New

func New(log zerolog.Logger, runner Runner) *Client

New creates a tmux client.

func NewDefault

func NewDefault(log zerolog.Logger) *Client

NewDefault creates a client that invokes the tmux executable.

func (*Client) AddWindows

func (c *Client) AddWindows(ctx context.Context, target multiplexer.Target, windows []multiplexer.WindowSpec) error

AddWindows adds windows to an existing tmux session.

func (*Client) AttachOrSwitch

func (c *Client) AttachOrSwitch(ctx context.Context, target multiplexer.Target, streams multiplexer.AttachStreams) error

AttachOrSwitch switches the active client inside tmux or attaches outside tmux. Window and pane selection is best-effort and ordered so the selected target is visible on entry: attach-session blocks until detach, so selection runs before it, while switch-client returns immediately, so selection runs after it.

func (*Client) Available

func (c *Client) Available() bool

Available reports whether tmux is available.

func (*Client) CapturePane

func (c *Client) CapturePane(ctx context.Context, target multiplexer.Target, opts multiplexer.CaptureOptions) (string, error)

CapturePane captures pane text.

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, spec multiplexer.SessionSpec) error

CreateSession creates a tmux session from a declarative specification.

func (*Client) CurrentSession

func (c *Client) CurrentSession(ctx context.Context) (multiplexer.Target, error)

CurrentSession returns the current tmux session, or an empty target outside tmux.

func (*Client) HasSession

func (c *Client) HasSession(ctx context.Context, target multiplexer.Target) (bool, error)

HasSession reports whether a tmux session exists.

func (*Client) InspectPane

func (c *Client) InspectPane(ctx context.Context, target multiplexer.Target) (multiplexer.Pane, error)

InspectPane returns one resolved pane.

func (*Client) KillSession

func (c *Client) KillSession(ctx context.Context, target multiplexer.Target) error

KillSession kills a tmux session.

func (*Client) KillWindow

func (c *Client) KillWindow(ctx context.Context, target multiplexer.Target) error

KillWindow kills one qualified tmux window.

func (*Client) ListPanes

func (c *Client) ListPanes(ctx context.Context) ([]multiplexer.Pane, error)

ListPanes returns every pane visible to the current tmux server.

func (*Client) OpenSession

func (c *Client) OpenSession(ctx context.Context, spec multiplexer.SessionSpec, selection multiplexer.Target) error

OpenSession creates a missing session or opens an existing one. For an existing session, selection names the window or pane to show on entry.

func (*Client) Paste

func (c *Client) Paste(ctx context.Context, target multiplexer.Target, text []byte, opts multiplexer.PasteOptions) (retErr error)

Paste loads bytes into a private tmux buffer and pastes it into a pane.

func (*Client) RenameSession

func (c *Client) RenameSession(ctx context.Context, target multiplexer.Target, newName string) error

RenameSession renames a tmux session.

func (*Client) ResolveTarget

func (c *Client) ResolveTarget(ctx context.Context, raw string) (multiplexer.Pane, error)

ResolveTarget resolves a tmux target into a qualified pane.

func (*Client) SendKey

func (c *Client) SendKey(ctx context.Context, target multiplexer.Target, key multiplexer.NamedKey) error

SendKey sends one validated tmux named-key token.

func (*Client) SendLiteral

func (c *Client) SendLiteral(ctx context.Context, target multiplexer.Target, text string) error

SendLiteral sends text without interpreting it as key names.

type ExecRunnerOptions

type ExecRunnerOptions struct {
	// Binary resolves the tmux executable for each command. Nil uses PATH.
	Binary func(context.Context) (string, error)
	// Environ returns the child environment. Nil inherits the process environment.
	Environ func(context.Context) []string
	// PrepareArgs can add server-selection arguments before execution.
	PrepareArgs func([]string) []string
}

ExecRunnerOptions configures an executable-backed Runner.

type Runner

type Runner interface {
	Available() bool
	Capture(ctx context.Context, args ...string) (stdout, stderr []byte, err error)
	Input(ctx context.Context, input io.Reader, args ...string) (stdout, stderr []byte, err error)
	Interactive(ctx context.Context, streams multiplexer.AttachStreams, args ...string) error
}

Runner executes tmux operations in captured, input-bearing, or interactive mode.

func NewExecRunner

func NewExecRunner(options ExecRunnerOptions) Runner

NewExecRunner creates a Runner that invokes a configurable tmux executable.

Jump to

Keyboard shortcuts

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