tmux

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagLastOutputAt = "@amux_last_output_at"
	TagLastInputAt  = "@amux_last_input_at"
)

Variables

This section is empty.

Functions

func AmuxSessionsByWorkspace

func AmuxSessionsByWorkspace(opts Options) (map[string][]string, error)

AmuxSessionsByWorkspace returns all @amux=1 sessions grouped by their @amux_workspace value. Sessions without a workspace tag are omitted.

func CapturePane

func CapturePane(sessionName string, opts Options) ([]byte, error)

CapturePane captures the scrollback history of a tmux pane (excluding the visible screen area) with ANSI escape codes preserved. Returns nil if the session has no scrollback or does not exist.

func CapturePaneTail

func CapturePaneTail(sessionName string, lines int, opts Options) (string, bool)

CapturePaneTail captures the last N lines of a session's active pane. Returns the content and a success flag. Returns ("", false) on error (e.g., session doesn't exist or capture times out).

func ClientCommand

func ClientCommand(sessionName, workDir, command string) string

func ClientCommandWithOptions

func ClientCommandWithOptions(sessionName, workDir, command string, opts Options) string

func ClientCommandWithTags

func ClientCommandWithTags(sessionName, workDir, command string, opts Options, tags SessionTags) string

func ClientCommandWithTagsAttach

func ClientCommandWithTagsAttach(sessionName, workDir, command string, opts Options, tags SessionTags, detachExisting bool) string

func ContentHash

func ContentHash(content string) [16]byte

ContentHash returns a fast hash of the content for change detection.

func EnsureAvailable

func EnsureAvailable() error

func InstallHint

func InstallHint() string

func KillSession

func KillSession(sessionName string, opts Options) error

func KillSessionsMatchingTags

func KillSessionsMatchingTags(tags map[string]string, opts Options) (bool, error)

KillSessionsMatchingTags kills sessions that match all provided tags.

func KillSessionsWithPrefix

func KillSessionsWithPrefix(prefix string, opts Options) error

KillSessionsWithPrefix kills all sessions with a matching name prefix.

func KillWorkspaceSessions

func KillWorkspaceSessions(wsID string, opts Options) error

KillWorkspaceSessions kills all sessions for a workspace ID.

func ListSessions

func ListSessions(opts Options) ([]string, error)

ListSessions returns all tmux session names for the configured server.

func ListSessionsMatchingTags

func ListSessionsMatchingTags(tags map[string]string, opts Options) ([]string, error)

ListSessionsMatchingTags returns sessions matching all provided tags.

func PanePIDs

func PanePIDs(sessionName string, opts Options) ([]int, error)

PanePIDs returns the PID of each pane's initial process in the given session. The -s flag lists panes across all windows in the session, not just the active one.

func SessionCreatedAt

func SessionCreatedAt(sessionName string, opts Options) (int64, error)

SessionCreatedAt returns the tmux session creation timestamp (unix seconds).

func SessionHasClients

func SessionHasClients(sessionName string, opts Options) (bool, error)

SessionHasClients reports whether the tmux session has any attached clients.

func SessionName

func SessionName(parts ...string) string

func SessionTagValue

func SessionTagValue(sessionName, key string, opts Options) (string, error)

SessionTagValue returns a session option value for the given tag key.

func SetMonitorActivityOn

func SetMonitorActivityOn(opts Options) error

SetMonitorActivityOn enables tmux monitor-activity globally. Called once at startup and when the tmux server name changes, rather than on every activity scan.

func SetSessionTagValue added in v0.0.12

func SetSessionTagValue(sessionName, key, value string, opts Options) error

SetSessionTagValue sets a tmux session option for the given session. Returns nil if the session no longer exists.

func SetStatusOff

func SetStatusOff(opts Options) error

SetStatusOff disables the tmux status line globally for the server.

Types

type Options

type Options struct {
	ServerName      string
	ConfigPath      string
	HideStatus      bool
	DisableMouse    bool
	DefaultTerminal string
	CommandTimeout  time.Duration
}

func DefaultOptions

func DefaultOptions() Options

type SessionActivity

type SessionActivity struct {
	Name        string
	WorkspaceID string
	TabID       string
	Type        string
	Tagged      bool
}

func ActiveAgentSessionsByActivity

func ActiveAgentSessionsByActivity(window time.Duration, opts Options) ([]SessionActivity, error)

ActiveAgentSessionsByActivity returns tagged agent sessions with recent tmux activity. Activity is derived from tmux's window_activity timestamp. Note: monitor-activity is set once at startup and per-session at creation via SetMonitorActivityOn, not on every scan.

type SessionState

type SessionState struct {
	Exists      bool
	HasLivePane bool
}

func SessionStateFor

func SessionStateFor(sessionName string, opts Options) (SessionState, error)

type SessionTagValues

type SessionTagValues struct {
	Name string
	Tags map[string]string
}

SessionTagValues stores tag values for a tmux session.

func SessionsWithTags

func SessionsWithTags(match map[string]string, keys []string, opts Options) ([]SessionTagValues, error)

SessionsWithTags returns sessions matching the provided tags, plus values for requested tag keys.

type SessionTags

type SessionTags struct {
	WorkspaceID string
	TabID       string
	Type        string
	Assistant   string
	CreatedAt   int64 // Unix seconds for fresh create/restart; may be zero for reattach.
	InstanceID  string
}

Jump to

Keyboard shortcuts

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