Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

925 symbols, extracted from source. Every type name in a signature links to its own entry; every cross-reference in a doc comment resolves against the same table.

By module 21 modules

Server 2 types, 2 functions and constants
Server 55 members

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

ConnectedServer 6 members

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

DaemonEpoch
typealias [source]
typealias [source]
DaemonEpoch

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

A restarted tmux on the same socket issues %0 again to a different pane, so an id from the previous run names nothing. Comparing epochs is what catches that, and it is why SessionRef and friends carry one.

DaemonIdentity
typealias [source]
typealias [source]
DaemonIdentity

Which tmux daemon answered, as tmux itself reports it.

A socket path names a place, not a process: kill-server and a restart give a new daemon the same path, and that daemon numbers its panes from %0 again. The pid alone is not enough — pids are reused — so the start time goes with it.

Session 2 types, 5 functions and constants
SessionWhere 35 members

Criteria matching a session, evaluated against one snapshot.

Session 32 members

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

SessionAliasMap
typealias [source]
typealias [source]
SessionAliasMap

The readable name this library gives each session format field.

A handle exposes both spellings: the alias, and tmux's own token through format. The alias is this library's, so a field with no entry here is reachable only by its tmux name.

SessionId
typealias [source]
typealias [source]
SessionId

A session ID in tmux's $n form.

SessionIdInput
typealias [source]
typealias [source]
SessionIdInput

Raw session-ID text or an authenticated session ID.

SessionRef
typealias [source]
typealias [source]
SessionRef

One session, named unambiguously across servers and daemon restarts.

SessionRow
typealias [source]
typealias [source]
SessionRow

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

Read through format when the aliased property names on the handle are not what a caller wants — a field tmux added in a later version has a token here whether or not this library has given it a name.

Window 3 types, 7 functions and constants
WindowWhere 41 members

Criteria matching a window, evaluated against one snapshot.

Window 37 members

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

ApplyWindowContext 3 members

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

WindowAliasMap
typealias [source]
typealias [source]
WindowAliasMap

The readable name this library gives each window format field.

A handle exposes both spellings: the alias, and tmux's own token through format. The alias is this library's, so a field with no entry here is reachable only by its tmux name.

WindowDirection
typealias [source]
typealias [source]
WindowDirection

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

tmux inserts at the next index before or after the target and moves the windows above it up to make room, so indices a caller is holding can shift. Without either direction the target index *is* the new window's place.

WindowId
typealias [source]
typealias [source]
WindowId

A window ID in tmux's @n form.

WindowIdInput
typealias [source]
typealias [source]
WindowIdInput

Raw window-ID text or an authenticated window ID.

WindowRef
typealias [source]
typealias [source]
WindowRef

One window, named unambiguously across servers and daemon restarts.

WindowRow
typealias [source]
typealias [source]
WindowRow

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

Read through format when the aliased property names on the handle are not what a caller wants — a field tmux added in a later version has a token here whether or not this library has given it a name.

WindowTarget
typealias [source]
typealias [source]
WindowTarget

A relative direction, or any window target tmux accepts.

The intersection keeps the three literals in autocomplete instead of letting the bare string swallow them.

Pane 2 types, 6 functions and constants
Pane 46 members

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

PaneWhere 83 members

Criteria matching a pane, evaluated against one snapshot.

PaneAliasMap
typealias [source]
typealias [source]
PaneAliasMap

The readable name this library gives each pane format field.

A handle exposes both spellings: the alias, and tmux's own token through format. The alias is this library's, so a field with no entry here is reachable only by its tmux name.

PaneDirection
typealias [source]
typealias [source]
PaneDirection

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

Above and Left are the same split as Below and Right with tmux's -b flag, so the geometry is identical and only the occupant differs.

PaneId
typealias [source]
typealias [source]
PaneId

A pane ID in tmux's %n form.

PaneIdInput
typealias [source]
typealias [source]
PaneIdInput

Raw pane-ID text or an authenticated pane ID.

PaneRef
typealias [source]
typealias [source]
PaneRef

One pane, named unambiguously across servers and daemon restarts.

PaneRow
typealias [source]
typealias [source]
PaneRow

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

Read through format when the aliased property names on the handle are not what a caller wants — a field tmux added in a later version has a token here whether or not this library has given it a name.

Client 2 types, 2 functions and constants
Client 12 members

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

ClientWhere 31 members

Criteria matching a client, evaluated against one snapshot.

ClientAliasMap
typealias [source]
typealias [source]
ClientAliasMap

The readable name this library gives each client format field.

A handle exposes both spellings: the alias, and tmux's own token through format. The alias is this library's, so a field with no entry here is reachable only by its tmux name.

ClientRow
typealias [source]
typealias [source]
ClientRow

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

Read through format when the aliased property names on the handle are not what a caller wants — a field tmux added in a later version has a token here whether or not this library has given it a name.

Hooks 1 function or constant
HookScope
typealias [source]
typealias [source]
HookScope

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

Options 2 functions and constants
DefaultOptionScope
typealias [source]
typealias [source]
DefaultOptionScope

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

Branded so it cannot be confused with an OptionScope : passing this means the call sends no scope flag, which is not the same as sending the session one.

OptionScope
typealias [source]
typealias [source]
OptionScope

Which table an option is read from or written to.

The scopes are not one chain. A pane option falls back to the window's, and an unset window or pane option falls back to the global window options; a session option falls back to the global session options, and server options belong to no session, window or pane at all. So setting something at window scope reaches every pane in it that has not set its own, and setting it at session scope does not.

Layout and geometry 6 functions and constants
ResizeAdjustmentDirection
typealias [source]
typealias [source]
ResizeAdjustmentDirection

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

The direction is where the boundary travels, not which pane grows: Up on a pane with a neighbour above it takes space from that neighbour.

SplitCellSize
typealias [source]
typealias [source]
SplitCellSize

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

Examples

import { splitSize } from "libtmux";
import type { SplitCellSize } from "libtmux";
const size: SplitCellSize = splitSize(20);
SplitPercentage
typealias [source]
typealias [source]
SplitPercentage

A canonical whole percentage from 0% through 100%.

Examples

import type { SplitPercentage } from "libtmux";
const size: SplitPercentage = "30%";
void size;
SplitSize
typealias [source]
typealias [source]
SplitSize

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

Examples

import type { SplitSize } from "libtmux";
const size: SplitSize = "30%";
void size;
isSplitSize ( value : : unknown ) → value is SplitSize
function [source]
function [source]
isSplitSize

Test whether a value is valid tmux split geometry.

Examples

import { isSplitSize } from "libtmux";
const value: unknown = "30%";
const size = isSplitSize(value) ? value : undefined;
splitSize ( value : : number ) → SplitCellSize ( value : : SplitPercentage ) → SplitPercentage ( value : : SplitSize ) → SplitSize ( value : : number | string ) → SplitSize
functionoverload4 overloads [source]
functionoverload4 overloads [source]
splitSize

Authenticate tmux split geometry or throw.

Examples

import { splitSize } from "libtmux";
const size = splitSize(20);
Environment 2 functions and constants
EnvironmentScope
typealias [source]
typealias [source]
EnvironmentScope

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

EnvironmentValue
typealias [source]
typealias [source]
EnvironmentValue

A variable's state in a tmux environment.

null is tmux's -NAME: the variable is present and marked for removal from the environment of any process tmux starts. Absent from the map is the third state, and means tmux carries no entry at all.

Versions 1 type
TmuxVersion 4 members

The tmux version a server is running.

Commands 1 type, 4 functions and constants
CommandOutcome 3 members

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

ConnectionAlias
typealias [source]
typealias [source]
ConnectionAlias

Which connection a handle came through.

Two servers on different sockets number their objects from the same place, so an id alone does not identify anything. This is the other half.

DaemonGuard
typealias [source]
typealias [source]
DaemonGuard

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

A tmux id is unique within one daemon and reissued by the next: kill-server and a restart give a new daemon the same socket, and it numbers its panes from %0 again. A handle captured before the restart therefore names something that exists, belongs to somebody else, and answers to the same command.

Checking first and sending second does not close that: the daemon can change between the two. if-shell -F does, because it is not a shell — tmux expands the format inside its command queue and cmdq_insert_afters the guarded command into the same queue, so nothing runs in between. The condition is pid and start_time together, since pids are reused.

The refusal has to be visible. tmux answers a false condition with no output and status 0, which is indistinguishable from a command that printed nothing, so the else branch is a freshly named unknown command. A 128-bit suffix makes matching a pre-existing command alias a guess, and the exact diagnostic distinguishes the refusal from the guarded command failing. The guarded command keeps its own stdout and stderr either way.

TmuxCommand
typealiasreadonly [source]
typealiasreadonly [source]
TmuxCommand

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

TmuxEngine
typealias [source]
typealias [source]
TmuxEngine

What runs a tmux command for a server.

Two obligations beyond returning bytes, and both are what the layers above assume rather than check:

Every request is one tmux invocation and carries its ordered command list. Keeping that structure at the seam prevents an engine from splitting a snapshot into several clients or guessing where global flags end. Environment, stdin, signal, and timeout apply once to the whole invocation.

daemonGuard, when a request carries one, must reach tmux — or the engine must be bound to one daemon for its lifetime, the way a control connection is. Ignoring it on a reconnecting engine means a handle read before a restart addressing whatever now holds its id. guardRequest is what the built-in engine calls to honour it, published so an implementer does not reproduce the wrapper, its else branch, and the stderr that tells refusal from failure.

Formats 1 type, 7 functions and constants
FormatSubscription 3 members

A format tmux expands and reports whenever its value changes.

DecodedFormatValue
typealias [source]
typealias [source]
DecodedFormatValue

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

FormatFieldName
typealias [source]
typealias [source]
FormatFieldName

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

Read from tmux's format.c rather than written by hand, so a field a newer tmux added is here as soon as the vocabulary is regenerated.

FormatIdentityType
typealias [source]
typealias [source]
FormatIdentityType

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

A field of one of these types carries an id a handle can be rebuilt from, which is why the row types refuse to report them as empty.

FormatScope
typealias [source]
typealias [source]
FormatScope

Which kind of object a format field describes.

A field belongs to exactly one scope, and asking a pane for a session's field is what #{} silently answers as empty rather than as an error.

FormatValueType
typealias [source]
typealias [source]
FormatValueType

The shapes tmux writes that are not simply text.

FormatValueTypes
typealias [source]
typealias [source]
FormatValueTypes

Which fields carry which shape.

Derived from tmux's own format.c and held to a live server by tests/integration/format_types.test.ts on every version CI runs.

Local: DecodedFormatValue is what a caller needs.

RawFormatValue
typealias [source]
typealias [source]
RawFormatValue

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

Queries 1 type, 14 functions and constants
RegexCriteriaData 2 members

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

ManyRelation
typealias [source]
typealias [source]
ManyRelation

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

At least one of the three must be given. every and none both hold vacuously for an empty collection, which is set theory rather than a bug, and some is what a caller usually wants instead.

ModelKindOf
typealias [source]
typealias [source]
ModelKindOf

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

NonZeroDigit
typealias [source]
typealias [source]
NonZeroDigit

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

OneRelation
typealias [source]
typealias [source]
OneRelation

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

null matches the absence itself — a pane whose window is no longer in the snapshot — rather than matching anything.

RawFlag
typealias [source]
typealias [source]
RawFlag

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

RawNumber
typealias [source]
typealias [source]
RawNumber

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

ScalarCriteria
typealias [source]
typealias [source]
ScalarCriteria

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

The bare value is shorthand for { equals: value }, and null matches a field tmux reports as unset rather than empty.

StringFilter
typealias [source]
typealias [source]
StringFilter

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

Written as a union so the type rejects {} — criteria that constrain nothing would match everything, which is never what a caller meant.

WhereDocumentV1
typealias [source]
typealias [source]
WhereDocumentV1

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

The version is in the payload because these cross a process boundary — an MCP client, a config file — where the reader's library may be older than the writer's. Nothing widens 1 in place; a new shape gets a new number.

WhereOf
typealias [source]
typealias [source]
WhereOf

The criteria a selection of this handle type accepts.

Written in terms of the handle rather than the kind so a caller holding a `Selection<Pane>` gets pane criteria without naming the kind twice.

compileBoundedRegex ( pattern : : string ) → RegExp
function [source]
function [source]
compileBoundedRegex

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

decodeWhereDocument ( input : : unknown ) → WhereDocumentV1
function [source]
function [source]
decodeWhereDocument

Validate a WHERE document and restore camelCase criteria names.

The returned document is canonical and deeply frozen.

Examples

import { decodeWhereDocument } from "libtmux/selection";
const document = decodeWhereDocument(
JSON.parse('{"model":"pane","version":1,"where":{"pane_title":"logs"}}'),
);
if (document.model === "pane") snapshot.panes.where(document.where);
Raises

Discussed in Filtering and queries

encodeWhereDocument ( document : : WhereDocumentV1 ) → string
function [source]
function [source]
encodeWhereDocument

Serialize a WHERE document as canonical JSON.

Field names and values use tmux's stable wire spellings. The input is validated without invoking accessors or conversion hooks.

Examples

import { encodeWhereDocument } from "libtmux";
const encoded = encodeWhereDocument({
model: "pane",
version: 1,
where: { title: { contains: "log" } },
});
Raises

Discussed in Filtering and queries

parseLegacyWhere ( model : : Model , input : : unknown ) → Extract<WhereDocumentV1, { readonly model: Model }>
function [source]
function [source]
parseLegacyWhere

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

Accepts one own data property on a plain object and never invokes accessors or conversion hooks. The returned document and its criteria are frozen.

Examples

import { parseLegacyWhere } from "libtmux/selection";
const document = parseLegacyWhere("window", { name__contains: "log" });
snapshot.windows.where(document.where);
Raises
  • QueryValidationError – when the model is not session or window, or the input is not exactly one string-valued name__contains property.

Queries — Fields 2 functions and constants
AliasedFields
typealias [source]
typealias [source]
AliasedFields

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

StringFilterFields
typealias [source]
typealias [source]
StringFilterFields

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.

The text side exists because the wire does. encodeFormatValue lowers every criterion to tmux's text before a query is serialized, and WhereDocumentV1 types both what a caller writes and what decodeWhereDocument gives back — so a type that refused text would be lying about the documents this library's own encoder produces. That is the difference from an ORM, whose query AST never round-trips through a type the caller also authors.

Raw is therefore not a taste. "0" | "1" is the exact wire domain for a flag, while an integer uses ${bigint} intersected with a decimal prefix. That rules out fractions, exponents, radix prefixes, leading zeroes, -0, NaN , and prose. TypeScript cannot bound an integer's magnitude, so the query validator also requires safe range at runtime. format_values.test.ts holds the layers in step.

The substring operations stay string deliberately: contains asks about the characters tmux sent, and a numeric field's text has characters like any other.

Snapshots 1 type
ServerSnapshot 4 members

An immutable view of the server at one instant.

Workspaces 2 functions and constants
CommandPolicy
typealias [source]
typealias [source]
CommandPolicy

When a pane's shell_command entries are sent to it.

create-only, the default, sends them only to panes this apply created. always sends them to every pane on every apply.

PrunePolicy
typealias [source]
typealias [source]
PrunePolicy

What to do with windows and panes the workspace does not describe.

Workspaces — Plans 11 types, 17 functions and constants
PanePlans 3 members

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

SessionPlans 2 members

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

PlannedOperation 2 members

A tmux command that has been described but not run.

WindowPlans 3 members

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

WorkspaceWindowPlacement 5 members

One existing window placement named by a workspace plan.

WorkspaceWindowCreation 2 members

A window that applying would create.

WorkspacePaneCreation 2 members

Panes that applying would create in one window position.

WorkspacePaneRemoval 2 members

Existing panes that applying would destroy.

WorkspaceWindowRemoval 2 members

How applying would remove an existing window placement.

WorkspaceWindowRename 3 members

One existing window rename, identified independently of its current name.

WorkspacePlan 8 members

Session, window, and pane membership changes an apply would make.

Workspace
typealias [source]
typealias [source]
Workspace

A validated workspace with every schema default and transform applied.

In other ports Describe a workspace as data
WorkspaceApplyMilestone
typealias [source]
typealias [source]
WorkspaceApplyMilestone

A high-level apply operation that finished before a later one failed.

WorkspaceApplyStage
typealias [source]
typealias [source]
WorkspaceApplyStage

The high-level operation an apply was attempting when it failed.

WorkspaceInput
typealias [source]
typealias [source]
WorkspaceInput

Workspace data before schema defaults and transforms are applied.

WorkspaceOptionValue
typealias [source]
typealias [source]
WorkspaceOptionValue

A value tmux stores for a session or window option.

WorkspacePane
typealias [source]
typealias [source]
WorkspacePane

A pane: a bare command string, or the settings the pane is created with.

WorkspaceRetention
typealias [source]
typealias [source]
WorkspaceRetention

Surplus topology retained because removing it would exceed the policy.

WorkspaceWindow
typealias [source]
typealias [source]
WorkspaceWindow

A window with every schema default applied.

WorkspaceWindowInput
typealias [source]
typealias [source]
WorkspaceWindowInput

A window as written, before panes defaults to one implicit pane.

applyWorkspace ( server : : Server , workspaceInput : : WorkspaceInput , options : : ApplyWorkspaceOptions = {} ) → Promise<Session>
functionasync [source]
functionasync [source]
applyWorkspace

Build a workspace into a real tmux session, or reconcile one that exists.

tmux gives every new session a window and every new window a pane, so the first window and first pane of each level are adopted rather than created. Creating them anyway is the classic workspace-builder bug that leaves an empty leading window behind.

What this reconciles is *topology*: which windows exist, in what order, under what names, with how many panes, under which layout. It is safe to apply twice and the second run does not duplicate anything. It is deliberately not a process supervisor — see CommandPolicy — and it does not unset options a previous version of the file had set, because tmux cannot say which of an option's current values this file is responsible for.

Raises
  • ZodError – when the workspace does not satisfy the strict config schema.

  • TypeError – when the operation options are invalid.

  • WorkspaceApplyError – when tmux fails after applying may have started.

Discussed in Workspaces · Build a workspace from a file · TypeScript workspace internals , TypeScript workspace builder API

In other ports Build a session from a workspace description
normalizeApplyWorkspaceOptions ( options : : ApplyWorkspaceOptions ) → { readonly commands: CommandPolicy; readonly prune: PrunePolicy; }
function [source]
function [source]
normalizeApplyWorkspaceOptions

Validate and snapshot apply options before server access.

normalizePlanWorkspaceOptions ( options : : PlanWorkspaceOptions ) → PrunePolicy
function [source]
function [source]
normalizePlanWorkspaceOptions

Validate and snapshot planning options before server access.

ownedByWorkspace ( session : : Session , name : : string ) → Promise<boolean>
functionasync [source]
functionasync [source]
ownedByWorkspace

Whether this session carries the mark for name.

parseWorkspace ( value : : unknown ) → Workspace
function [source]
function [source]
parseWorkspace

Validate a parsed workspace, rejecting anything the schema does not allow.

Discussed in TypeScript workspace internals , Use the TypeScript workspace builder , TypeScript workspace builder API

parseWorkspaceYaml ( source : : string ) → Workspace
function [source]
function [source]
parseWorkspaceYaml

Parse a YAML or JSON workspace, then validate it.

YAML parsing is Bun's, and this package otherwise runs anywhere — so this is the one function that does not. Reached from Node it says so, rather than failing on an undefined global; parse the document yourself and hand the result to parseWorkspace .

Discussed in Use the TypeScript workspace builder , TypeScript workspace builder API

planWorkspace ( server : : Server , workspaceInput : : WorkspaceInput , options : : PlanWorkspaceOptions = {} ) → Promise<WorkspacePlan>
functionasync [source]
functionasync [source]
planWorkspace

Plan session, window, and pane membership without changing tmux.

Reads the server once and answers from that capture, so it costs one snapshot and changes nothing. It reports structural creation, removal, retention, and window renames. It does not predict options, layouts, focus, or pane command effects.

Examples

const plan = await planWorkspace(server, workspace);
if (plan.removesWindows.length > 0) console.log("would remove", plan.removesWindows);
Raises
  • ZodError – when the workspace does not satisfy the strict config schema.

  • TypeError – when planning options are invalid.

Discussed in TypeScript workspace internals , Use the TypeScript workspace builder , TypeScript workspace builder behavior , TypeScript workspace builder API

planWorkspace ( server : : Server , workspace : : Workspace , prune : : PrunePolicy ) → Promise<WorkspacePlan>
functionasync [source]
functionasync [source]
planWorkspace
Workspaces — Session 2 functions and constants
claimSession ( session : : Session , name : : string ) → Promise<void>
functionasync [source]
functionasync [source]
claimSession

Claim a session this apply created.

runningSession ( server : : Server , name : : string ) → Promise<Session | undefined>
functionasync [source]
functionasync [source]
runningSession

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

Acquisition raises on an unreachable server rather than reading as empty, which is the answer a caller asking what is there needs. Building from nothing is the ordinary starting point here, though, and a socket with no daemon behind it is holding this session in the way an empty server is: not at all.

Workspaces — Functions 7 functions and constants
mayPrune ( policy : : PrunePolicy , owned : : boolean ) → boolean
function [source]
function [source]
mayPrune

Whether surplus topology may be removed.

owned is the default because it is the only one that is safe without knowing where the session came from: a workspace prunes what it built and leaves alone what it merely found. always authorizes pruning for one operation; it does not stamp or otherwise adopt the session.

optionValue ( value : : WorkspaceOptionValue ) → string
function [source]
function [source]
optionValue

Convert a YAML scalar to the string tmux accepts for an option value.

paneCommands ( pane : : WorkspacePane , window : : WorkspaceWindow ) → readonly string[]
function [source]
function [source]
paneCommands

Normalize a pane entry to the commands it should run, in order.

A window's shell_command_before runs in every one of its panes, ahead of that pane's own commands, which is how tmuxp seeds a common environment.

paneStartDirectory ( pane : : WorkspacePane , window : : WorkspaceWindow , workspace : : Workspace ) → string | undefined
function [source]
function [source]
paneStartDirectory

A pane's start directory, falling back to its window's and then the session's.

paneWantsFocus ( pane : : WorkspacePane ) → boolean
function [source]
function [source]
paneWantsFocus

Whether a pane entry asked to be the focused one.

windowIsShared ( window : : Window ) → boolean
function [source]
function [source]
windowIsShared
windowStartDirectory ( window : : WorkspaceWindow , workspace : : Workspace ) → string | undefined
function [source]
function [source]
windowStartDirectory

A window's directory, inherited from its workspace when it has none.

Requests 2 functions and constants
GuardedTmuxRequest
typealias [source]
typealias [source]
GuardedTmuxRequest

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

TmuxInvocationRequest
typealias [source]
typealias [source]
TmuxInvocationRequest

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

tmux runs a command list until one fails and discards the rest, so the list is the unit of atomicity a caller gets. The daemon guard is what stops a raw tmux id being applied to whatever a restarted server reissued it to.

Errors 17 types, 5 functions and constants
ExceptionOptions 2 members

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

ObjectNotFoundOptions 2 members

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

MultipleObjectsErrorOptions 1 members

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

TmuxCommandFailureOptions 5 members

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

LibTmuxError 4 members

The base of every error this library raises.

TmuxTransportError 9 members

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

TmuxTransportErrorOptions 5 members

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

ObjectNotFoundError 3 members

A lookup that required one object found none.

MultipleObjectsError 4 members

A lookup that required one object found several.

TmuxObjectNotFoundError 2 members

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

VersionTooLowError 5 members

A field the server is too old to have.

WaitTimeoutError 1 members

A wait reached its deadline with the condition still unmet.

NoMatchError 1 members

A selection that required exactly one match found none.

MultipleMatchesError 1 members

A selection that required exactly one match found several.

QueryValidationError 4 members

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

TmuxCommandError 8 members

A tmux command that exited non-zero.

WorkspaceApplyError 4 members

Applying stopped after tmux may already have changed.

LibTmuxErrorCode
typealias [source]
typealias [source]
LibTmuxErrorCode

Every value LibTmuxError.code can hold.

A union rather than string so a comparison against a name this package does not have is a type error rather than a branch that never runs.

Each class declares this type rather than its own literal because the hierarchy is three deep in places — NoMatchError extends ObjectNotFoundError — and a literal on the parent makes the child's declaration an illegal override. instanceof is the narrowing tool; this is the one that survives a bundler and a serialization round trip.

Query
typealias [source]
typealias [source]
Query

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

Kept as the caller wrote it rather than as a formatted sentence, so a caller that built the criteria from a form or a config file can point at the field that was wrong. The message renders it; this is the source.

QueryValidationErrorCode
typealias [source]
typealias [source]
QueryValidationErrorCode
QueryValidationReason
typealias [source]
typealias [source]
QueryValidationReason

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

TmuxTransportErrorKind
typealias [source]
typealias [source]
TmuxTransportErrorKind

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

Errors — Server 1 type
TmuxServerRestartedError 3 members

A handle outlived the daemon that issued its id.

Constants and enums 32 types, 5 functions and constants
CommandOptions 3 members

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

CommandResult 4 members

A finished tmux invocation, as the process left it.

SplitOptions 6 members

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

SendKeysOptions 2 members

How the keys are interpreted before tmux delivers them.

CmdOptions 1 members

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

JoinOptions 2 members

Options for joining a pane into another window.

SetOptionOptions 1 members

Options for writing a tmux option.

CaptureOptions 5 members

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

SetHookOptions 1 members

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

ResizeOptions 4 members

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

RunShellOptions 1 members

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

IfShellOptions 3 members

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

RespawnOptions 3 members

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

PopupOptions 4 members

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

ChooseTreeOptions 2 members

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

SetEnvironmentOptions 2 members

Options for writing a tmux environment variable.

TmuxOutputEvent 4 members

A pane produced output.

TmuxSubscriptionEvent 7 members

A subscribed format expanded to a new value.

TmuxLayoutChangeEvent 5 members

A window's layout changed.

TmuxPasteBufferEvent 2 members

A paste buffer was written or deleted.

TmuxMessageEvent 2 members

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

TmuxExitEvent 2 members

The control-mode connection is ending.

TmuxUnknownEvent 3 members

A notification this version of the package does not model.

TmuxReconnectedEvent 2 members

The connection dropped and was reopened.

TmuxReconnectingEvent 2 members

The connection dropped and a replacement is being opened.

ConnectionOptions 4 members

Options shared by connected servers and event observers.

WaitForOptions 2 members

Timing for a whole-server state wait.

WatchOptions 2 members

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

ApplyWorkspaceOptions 2 members

How applyWorkspace should treat a workspace that is already running.

PlanWorkspaceOptions 1 members

Structural planning options; pane command delivery is apply-only.

ConnectOptions
typealias [source]
typealias [source]
ConnectOptions

Options for Server.connect .

TmuxCommandResult
typealias [source]
typealias [source]
TmuxCommandResult

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

A returncode of zero and a signal of null together mean tmux ran and answered; either one set means it did not finish, and stderr says why.

TmuxEvent
typealias [source]
typealias [source]
TmuxEvent

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

tmux pushes these; nothing here asked for them, and they arrive interleaved with command replies. The union is open in practice — an unrecognised notification arrives as TmuxUnknownEvent rather than being dropped, so a switch should still have a default.

TmuxIdKind
typealias [source]
typealias [source]
TmuxIdKind

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

The three are numbered independently, so $1, @1 and %1 can all exist at once and name unrelated objects. The kind is what keeps a pane id from being passed where a window id belongs.

WhereForKind
typealias [source]
typealias [source]
WhereForKind

The criteria shape belonging to one model kind.

Constants and enums — Server 1 type
ServerOptions 10 members

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

Constants and enums — Session 5 types
NewSessionOptions 8 members

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

TmuxSessionEvent 3 members

The attached session changed, or a session was renamed.

TmuxSessionsChangedEvent 1 members

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

TmuxSessionWindowChangedEvent 3 members

A session's active window changed.

TmuxClientSessionChangedEvent 4 members

Another client switched sessions.

Constants and enums — Window 6 types
NewWindowOptions 5 members

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

MoveWindowOptions 2 members

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

ResizeWindowOptions 2 members

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

TmuxWindowLifecycleEvent 2 members

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

TmuxWindowPaneChangedEvent 3 members

The active pane of a window changed.

Constants and enums — Pane 2 types
TmuxPaneModeChangedEvent 2 members

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

TmuxPaneFlowEvent 2 members

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

Constants and enums — Client 1 type
TmuxClientDetachedEvent 2 members

Another client detached.

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

What every recorded entry carries, answered or not.

RecordedAnswer 3 members

One invocation and what tmux answered, as JSON.

RecordedError 8 members

One invocation that raised instead of answering.

RecordedFailure 1 members

One invocation that failed, and how.

TmuxRecording 2 members

Every invocation one run made, in order.

RecordedInvocation
typealias [source]
typealias [source]
RecordedInvocation

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

A failure is written down rather than dropped because the queue is positional. An omitted failure does not merely lose itself — it hands the next call the answer belonging to the one after it, so a recorded failure replays as a pass and everything past it is off by one.

recordInvocations ( inner : : TmuxEngine = new NodeSpawnTransport() ) → { readonly engine: TmuxEngine; /** The recording so far, safe to serialize at any point. */ readonly recording: () => TmuxRecording; }
function [source]
function [source]
recordInvocations

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

The wrapper is transparent: it answers exactly what the inner engine answered, so a suite can record while it runs against real tmux and keep asserting on the real results. Called with nothing it wraps the engine a Server builds for itself, which is what recording against a local tmux means and saves reaching for an internal class to say so.

replayInvocations ( recording : : TmuxRecording ) → TmuxEngine
function [source]
function [source]
replayInvocations

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

Repeated identical commands answer in the order they were recorded, because two snapshots of a changing server are the same argv and different answers. An argv the recording does not hold raises rather than inventing a result: a test whose code took a path the recording never saw should say so, not quietly pass against an empty server.

Other 6 types, 15 functions and constants
TmuxInvocationReport 6 members

What one tmux invocation cost and how it ended.

LogicalRefBase 4 members

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

Selection 12 members

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

MenuEntry 3 members

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

AbortLike 4 members

The part of AbortSignal this package uses.

TmuxEventStream 5 members

A live stream of tmux control-mode events.

DeliveryStatus
typealias [source]
typealias [source]
DeliveryStatus

How far a command got before something interrupted it.

This is what a caller needs to decide whether retrying is safe: a command that was never written changed nothing, and one that was written but not answered may have done its work already. indeterminate is the honest answer, not a missing one.

Digit
typealias [source]
typealias [source]
Digit

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

These three exist so "101%" is a compile error rather than a runtime one.

LogicalRef
typealias [source]
typealias [source]
LogicalRef

Any of the three, discriminated by kind .

Clients are absent on purpose: a client has a name rather than an id, and nothing numbers it.

MenuItem
typealias [source]
typealias [source]
MenuItem

A menu entry, or a horizontal rule.

tmux spells a separator as one empty argument rather than a name/key/command triple, so modelling it as a distinct value keeps callers from fabricating empty fields that tmux would reject.

NonZeroDigit
typealias [source]
typealias [source]
NonZeroDigit

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

OperationStatus
typealias [source]
typealias [source]
OperationStatus

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

skipped is not a failure: a step whose precondition no longer holds is reported rather than retried, so the caller sees why the whole did less than it asked for.

RowWithIdentities
typealias [source]
typealias [source]
RowWithIdentities

A raw format row whose listed identity fields are present.

SafeInteger
typealias [source]
typealias [source]
SafeInteger

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

Examples

import { safeInteger } from "libtmux";
import type { SafeInteger } from "libtmux";
const count: SafeInteger = safeInteger(3);
TmuxId
typealias [source]
typealias [source]
TmuxId

A tmux object ID authenticated for one object kind.

TmuxIdInput
typealias [source]
typealias [source]
TmuxIdInput

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

TmuxInvocationObserver
typealias [source]
typealias [source]
TmuxInvocationObserver

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

This is the seam for logs, traces and metrics: a caller that wants to see what the library is doing has otherwise to supply a whole engine. It runs after the invocation is decided and cannot change its outcome — anything it throws is swallowed, because a command must not fail on account of the code watching it.

Returning a promise is allowed and never awaited: the invocation has already been decided, so waiting would only delay it. A rejection is swallowed on the same grounds as a throw, rather than left to the host's unhandled rejection policy.

ZeroToNinetyNine
typealias [source]
typealias [source]
ZeroToNinetyNine

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

isSafeInteger ( value : : unknown ) → value is SafeInteger
function [source]
function [source]
isSafeInteger

Test whether a value is an exact JavaScript integer.

Examples

import { isSafeInteger } from "libtmux";
const value: unknown = 3;
if (isSafeInteger(value)) snapshot.sessions.where({ attached: value });
isTmuxName ( value : : unknown ) → value is string
function [source]
function [source]
isTmuxName

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

The refusal the mutating calls apply, offered ahead of them so a caller validating configuration can report the bad field rather than catching a TypeError from the call it fed.

Examples

import { isTmuxName } from "libtmux";
const value: unknown = "work";
const name = isTmuxName(value) ? value : undefined;
safeInteger ( value : : number ) → SafeInteger
function [source]
function [source]
safeInteger

Authenticate an exact JavaScript integer or throw.

Examples

import { safeInteger } from "libtmux";
const pid = safeInteger(42);
Raises
Esc

Type to search.