Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

TypeScript API

API reference

Browse the TypeScript types and operations for working with tmux. Start with the core objects below, or search for a type or member.

Server 2 types, 2 functions and constants
Server class 56 members

One tmux server, addressed by the socket it listens on.

ConnectedServer interface 6 members

A server with a persistent observation connection and daemon-lifetime tracking.

DaemonEpoch type alias

Which run of the daemon a handle came from, counted from zero.

DaemonIdentity type alias

Which tmux daemon answered, as tmux itself reports it.

Session 2 types, 5 functions and constants
Session class 32 members

One session on one tmux server, as a handle rather than a copy of it.

SessionWhere interface 35 members

Criteria matching a session, evaluated against one snapshot.

SessionId type alias

A session ID in tmux's $n form.

SessionIdInput type alias

Raw session-ID text or an authenticated session ID.

SessionRef type alias

One session, named unambiguously across servers and daemon restarts.

SessionAliasMap type alias

The readable name this library gives each session format field.

SessionRow type alias

The tmux format fields a session handle is built from, by tmux's own names.

Window 4 types, 6 functions and constants
Window class 37 members

One window on one tmux server, as a handle rather than a copy of it.

WindowDirection type alias 2 members

Where a new window lands relative to the one it was created from.

WindowWhere interface 41 members

Criteria matching a window, evaluated against one snapshot.

ApplyWindowContext interface 4 members

What applying one window needs to know beyond the window itself.

WindowId type alias

A window ID in tmux's @n form.

WindowIdInput type alias

Raw window-ID text or an authenticated window ID.

WindowRef type alias

One window, named unambiguously across servers and daemon restarts.

WindowAliasMap type alias

The readable name this library gives each window format field.

WindowTarget type alias

A relative direction, or any window target tmux accepts.

WindowRow type alias

The tmux format fields a window handle is built from, by tmux's own names.

Pane 3 types, 5 functions and constants
Pane class 46 members

One pane on one tmux server, as a handle rather than a copy of it.

PaneDirection type alias 4 members

Which side of the current pane a split puts the new one on.

PaneWhere interface 83 members

Criteria matching a pane, evaluated against one snapshot.

PaneId type alias

A pane ID in tmux's %n form.

PaneIdInput type alias

Raw pane-ID text or an authenticated pane ID.

PaneRef type alias

One pane, named unambiguously across servers and daemon restarts.

PaneAliasMap type alias

The readable name this library gives each pane format field.

PaneRow type alias

The tmux format fields a pane handle is built from, by tmux's own names.

Client 2 types, 2 functions and constants
Client class 12 members

One client attached to a tmux server, as a handle rather than a copy of it.

ClientWhere interface 31 members

Criteria matching a client, evaluated against one snapshot.

ClientRow type alias

The tmux format fields a client handle is built from, by tmux's own names.

ClientAliasMap type alias

The readable name this library gives each client format field.

Hooks 1 function or constant
HookScope type alias

The server, session, window, or pane table that holds a hook.

Options 1 type, 1 function or constant
OptionScope type alias 4 members

Which table an option is read from or written to.

"Whatever scope tmux would use", as a value rather than an absent argument.

Layout and geometry 1 type, 5 functions and constants
ResizeAdjustmentDirection type alias 4 members

Which edge a resize moves, in tmux's own terms.

SplitCellSize type alias

A nonnegative cell count within tmux's signed 32-bit geometry range.

SplitPercentage type alias

A canonical whole percentage from 0% through 100%.

SplitSize type alias

An authenticated cell count or canonical percentage for a pane split.

isSplitSize function

Test whether a value is valid tmux split geometry.

splitSize function

Authenticate tmux split geometry or throw.

Environment 2 functions and constants
EnvironmentScope type alias

Environments live at server (global) or session scope, as hooks do.

EnvironmentValue type alias

A variable's state in a tmux environment.

Versions 1 type
TmuxVersion interface 4 members

The tmux version a server is running.

Commands 1 type, 4 functions and constants
CommandOutcome interface 3 members

One command's result together with how far it got.

ConnectionAlias type alias

Which connection a handle came through.

DaemonGuard type alias

Making a command refuse to run on a daemon that is not the one it was read from.

TmuxCommand type alias

One nonempty tmux command, before command-list separators are inserted.

TmuxEngine type alias

What runs a tmux command for a server.

Formats 1 type, 7 functions and constants
FormatSubscription interface 3 members

A format tmux expands and reports whenever its value changes.

FormatScope type alias

Which kind of object a format field describes.

FormatFieldName type alias

Every format field this tmux vocabulary knows, by tmux's own token.

FormatValueType type alias

The shapes tmux writes that are not simply text.

The three shapes that name a tmux object rather than describe one.

FormatValueTypes type alias

Which fields carry which shape.

RawFormatValue type alias

The raw text tmux writes, authenticated where it carries an identity.

What a caller reads for one field, once the text has been decoded.

Queries 1 type, 14 functions and constants
RegexCriteriaData interface 2 members

A pattern and its flags, kept apart from any regular-expression object.

ModelKindOf type alias

Which of the four criteria shapes a handle type is matched with.

StringFilter type alias

A text comparison, of which exactly one form must be given.

NonZeroDigit type alias In selection

A leading digit, which tmux never writes as 0 in a multi-digit number.

RawNumber type alias

The decimal text tmux sends for a field it reports as a number or timestamp.

RawFlag type alias

The text tmux sends for a flag: it writes these two and nothing else.

ScalarCriteria type alias

One field's criteria: a value to equal, or a filter describing how to compare.

ManyRelation type alias

How criteria apply to a collection: to any of it, all of it, or none.

OneRelation type alias

How criteria apply to a single related object, which may be absent.

WhereOf type alias

The criteria a selection of this handle type accepts.

WhereDocumentV1 type alias

Criteria as a portable document: which model, which version, and the criteria themselves.

Compile a regex under the deterministic selection-query work budget.

Validate a WHERE document and restore camelCase criteria names.

Serialize a WHERE document as canonical JSON.

Convert the Python port's name__contains spelling to canonical criteria.

Queries — Fields 2 functions and constants
AliasedFields type alias

Idiomatic property names layered over a row, carrying decoded values.

A field's criteria accept its decoded shape as well as the text tmux sends: where({ active: true }) and where({ active: "1" }) are the same query, and serialize identically. A null criterion matches any wire value that the field decoder treats as absent or invalid, rather than one particular wire spelling.

Snapshots 1 type
ServerSnapshot interface 5 members

An immutable view of the server at one instant.

Workspaces — Plans 4 types, 3 functions and constants
PanePlans interface 3 members

What Pane.plan() offers, one entry per mutation it can describe.

SessionPlans interface 2 members

What Session.plan() offers, one entry per mutation it can describe.

PlannedOperation interface 2 members

A tmux command that has been described but not run.

WindowPlans interface 3 members

What Window.plan() offers, one entry per mutation it can describe.

Validate and snapshot apply options before server access.

Validate and snapshot planning options before server access.

planWorkspace function
Workspaces — Session 1 function or constant

The session this workspace names, on a server that may not be running yet.

Workspaces — Functions 1 function or constant
Requests 2 functions and constants

What an engine is asked to run: one ordered command list, and the daemon it must still be talking to.

A daemon-guarded request paired with its exact refusal detector.

Errors 16 types, 5 functions and constants
ExceptionOptions interface 2 members

What any of these errors accepts: the cause, and the tmux command that ran.

ObjectNotFoundOptions interface 2 members

The criteria that found nothing, and an optional message replacing the built one.

MultipleObjectsErrorOptions interface 1 member

The criteria that matched too much, with how many it matched when known.

TmuxCommandFailureOptions interface 5 members

What a failed tmux invocation reported, before it is turned into a message.

LibTmuxError class 4 members

The base of every error this library raises.

TmuxTransportError class 9 members

A command did not complete, and this is how far it got.

TmuxTransportErrorOptions interface 5 members

What the transport observed when a command did not come back.

ObjectNotFoundError class 3 members

A lookup that required one object found none.

MultipleObjectsError class 4 members

A lookup that required one object found several.

TmuxObjectNotFoundError class 2 members

A tmux object named by id was not in the list tmux returned.

VersionTooLowError class 5 members

A field the server is too old to have.

WaitTimeoutError class 1 member

A wait reached its deadline with the condition still unmet.

NoMatchError class 1 member

A selection that required exactly one match found none.

MultipleMatchesError class 1 member

A selection that required exactly one match found several.

QueryValidationError class 4 members

Criteria that could not be evaluated, rejected before any command ran.

TmuxCommandError class 8 members

A tmux command that exited non-zero.

Query type alias

The criteria a lookup was given, carried on the error it raised.

LibTmuxErrorCode type alias

Every value LibTmuxError.code can hold.

What went wrong between this process and tmux, as opposed to inside tmux.

Which half of a lookup was malformed: the id, or the criteria around it.

Errors — Server 1 type

A handle outlived the daemon that issued its id.

Constants and enums 30 types, 5 functions and constants
CommandOptions interface 3 members

What every command accepts, whichever handle it is called on.

CommandResult interface 4 members

A finished tmux invocation, as the process left it.

SnapshotOptions interface 1 member

Options for Server.snapshot().

SplitOptions interface 6 members

Which side the new pane takes, how big it is, and what runs in it.

SendKeysOptions interface 2 members

How the keys are interpreted before tmux delivers them.

CmdOptions interface 1 member

Options for Server.cmd() and the handle-level cmd.

JoinOptions interface 2 members

Options for joining a pane into another window.

SetOptionOptions interface 1 member

Options for writing a tmux option.

CaptureOptions interface 5 members

Which part of a pane is read, and in what form.

SaveBufferOptions interface 1 member
SetHookOptions interface 1 member

Which hook table the binding is written to, and whether it replaces or adds.

ResizeOptions interface 4 members

How far a pane boundary moves, and in which direction.

RunShellOptions interface 1 member

Where the shell command runs, and whether the call waits for it.

IfShellOptions interface 3 members

How the condition is decided: by running it, or by expanding it.

RespawnOptions interface 3 members

Whether a pane whose process is still alive may be restarted.

PopupOptions interface 4 members

Size, placement and lifetime of a popup, which floats over the window rather than taking space from it.

ChooseTreeOptions interface 2 members

What the interactive chooser shows and what selecting a row runs.

SetEnvironmentOptions interface 2 members

Options for writing a tmux environment variable.

TmuxOutputEvent interface 4 members

A pane produced output.

TmuxSubscriptionEvent interface 7 members

A subscribed format expanded to a new value.

TmuxLayoutChangeEvent interface 5 members

A window's layout changed.

TmuxPasteBufferEvent interface 2 members

A paste buffer was written or deleted.

TmuxMessageEvent interface 2 members

tmux reported a message, or an error in its configuration.

TmuxExitEvent interface 2 members

The control-mode connection is ending.

TmuxUnknownEvent interface 3 members

A notification this version of the package does not model.

TmuxReconnectedEvent interface 2 members

The connection dropped and was reopened.

TmuxReconnectingEvent interface 2 members

The connection dropped and a replacement is being opened.

ConnectionOptions interface 4 members

Options shared by connected servers and event observers.

WaitForOptions interface 2 members

Timing for a whole-server state wait.

WatchOptions interface 2 members

Options for Server.watch(), a notification-only observer.

TmuxIdKind type alias

Which of tmux's three id spaces an id belongs to.

What an engine reports back: the process's own exit, not tmux's opinion of it.

WhereForKind type alias

The criteria shape belonging to one model kind.

TmuxEvent type alias

Anything a control-mode connection can deliver, as one discriminated union.

ConnectOptions type alias

Options for Server.connect().

Constants and enums — Server 1 type
ServerOptions interface 10 members

How to reach a tmux server, and what to assume when it is quiet.

Constants and enums — Session 5 types
NewSessionOptions interface 8 members

What a new session starts as, and what it is grouped with.

TmuxSessionEvent interface 3 members

The attached session changed, or a session was renamed.

TmuxSessionsChangedEvent interface 1 member

The set of sessions changed. Carries no payload; re-read the server.

TmuxSessionWindowChangedEvent interface 3 members

A session's active window changed.

TmuxClientSessionChangedEvent interface 4 members

Another client switched sessions.

Constants and enums — Window 6 types
NewWindowOptions interface 6 members

Where a new window lands, and what runs in it.

MoveWindowOptions interface 2 members

Where a window is moved to, and what happens if something is already there.

ResizeWindowOptions interface 2 members

How far a window's own size moves, or what it is set to outright.

TmuxWindowLifecycleEvent interface 2 members

A window was added, closed, or linked into or out of a session.

TmuxWindowRenamedEvent interface 3 members

A window was renamed.

TmuxWindowPaneChangedEvent interface 3 members

The active pane of a window changed.

Constants and enums — Pane 2 types
TmuxPaneModeChangedEvent interface 2 members

A pane entered or left a mode such as copy mode.

TmuxPaneFlowEvent interface 2 members

tmux paused or resumed output for a pane that fell behind.

Constants and enums — Client 1 type
TmuxClientDetachedEvent interface 2 members

Another client detached.

Testing utilities 5 types, 3 functions and constants
RecordedCall interface 2 members

What every recorded entry carries, answered or not.

RecordedAnswer interface 3 members

One invocation and what tmux answered, as JSON.

RecordedError interface 8 members

One invocation that raised instead of answering.

RecordedFailure interface 1 member

One invocation that failed, and how.

TmuxRecording interface 2 members

Every invocation one run made, in order.

One entry: either an answer or a failure, never both.

Wrap an engine so every invocation it runs is written down.

An engine that answers from a recording and never starts a process.

Other 6 types, 15 functions and constants
TmuxInvocationReport interface 6 members

What one tmux invocation cost and how it ended.

LogicalRefBase interface 4 members

The three parts that together name one tmux object for certain.

Selection interface 12 members

An immutable, ordered set of tmux objects read at one instant.

MenuEntry interface 3 members

One selectable line of a menu: its label, its shortcut, and what it runs.

AbortLike interface 4 members

The part of AbortSignal this package uses.

TmuxEventStream interface 5 members

A live stream of tmux control-mode events.

TmuxId type alias

A tmux object ID authenticated for one object kind.

TmuxIdInput type alias

Raw text or an already-authenticated ID of the expected kind.

SafeInteger type alias

A finite whole number within JavaScript's safe integer range.

DeliveryStatus type alias

How far a command got before something interrupted it.

OperationStatus type alias

What became of one step of a multi-step operation.

Called once per tmux invocation, after it answers or fails.

LogicalRef type alias

Any of the three, discriminated by kind.

A raw format row whose listed identity fields are present.

Digit type alias

One decimal character, for building a percentage's shape in the type system.

NonZeroDigit type alias In types

A leading digit, so "07%" is not a percentage.

ZeroToNinetyNine type alias

Every whole number a percentage may start with, short of one hundred.

MenuItem type alias

A menu entry, or a horizontal rule.

isSafeInteger function

Test whether a value is an exact JavaScript integer.

isTmuxName function

Test whether a value is a name every supported tmux stores unchanged.

safeInteger function

Authenticate an exact JavaScript integer or throw.

By module 21 modules

Esc

Type to search.

Reference previewOpen reference