libtmux Reference MCP Search
On this page

selection.Selection.one

View as Markdown

Module
selection
Declared in
Selection
Package
@libtmux/libtmux
Source
packages/libtmux/src/selection.ts
one ( criteria : : WhereOf<Model> ) Model
method [source]
method [source]
one

The single member, or the single one matching criteria.

Throws NoMatchError for none and MultipleMatchesError for several, so "exactly one" is enforced rather than assumed — a first that silently takes the head of two is how the wrong pane gets driven.

An id is not always one member. A window linked into two sessions, or shared by two grouped sessions, has a placement in each and both carry the same id, so one({ id }) raises for a perfectly good id. Add the session to say which placement is meant.

Examples

const only = snapshot.sessions.one({ name: "work" });
only.id;

Discussed in Filtering and queries

0 declared, 0 inherited

Esc

Type to search.