libtmux Reference MCP Search
On this page

C++ API reference

777 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 14 modules

  • libtmux 127
  • abi.hpp 3
  • capabilities.hpp 2
  • libtmux::client 8
  • libtmux::detail 6
  • libtmux::FilterExpr 6
  • libtmux::NotificationRange 1
  • libtmux::pane 15
  • libtmux::session 8
  • libtmux::test 11
  • libtmux::tmuxq 1
  • libtmux::window 13
  • std::hash<libtmux 4
  • Types 4
Server 4 types
Session 2 types
Window 2 types
Pane 2 types
Client 2 types
Options 1 type
Buffers 1 type
Versions 1 type
Commands 11 types
Control mode 10 types
Formats 2 types
Queries 1 type
Queries — Fields 6 types
Queries — Operators 5 types
Queries — Expressions 2 types
Snapshots 2 types
Requests 2 types
Errors 7 types
Constants and enums 7 types
Constants and enums — Session 1 type
Constants and enums — Window 1 type
Testing utilities 10 types
Other 4 types
Functions and constants 0 types
active : BoolFieldHandle< Pane >
attribute [source]
attribute [source]
active
active : BoolFieldHandle< Window >
attribute [source]
attribute [source]
active
activity : BoolFieldHandle< Window >
attribute [source]
attribute [source]
activity
attached : BoolFieldHandle< Session >
attribute [source]
attribute [source]
attached
attribute [source]
attribute [source]
bell
client_count : NumberFieldHandle< Session >
attribute [source]
attribute [source]
client_count
command : StringFieldHandle< Pane >
attribute [source]
attribute [source]
command
control_mode : BoolFieldHandle< Client >
attribute [source]
attribute [source]
control_mode
dead : BoolFieldHandle< Pane >
attribute [source]
attribute [source]
dead
attribute [source]
attribute [source]
group
grouped : BoolFieldHandle< Session >
attribute [source]
attribute [source]
grouped
attribute [source]
attribute [source]
height
height : NumberFieldHandle< Pane >
attribute [source]
attribute [source]
height
attribute [source]
attribute [source]
height
attribute [source]
attribute [source]
id
attribute [source]
attribute [source]
id
attribute [source]
attribute [source]
id
in_mode : BoolFieldHandle< Pane >
attribute [source]
attribute [source]
in_mode
index : NumberFieldHandle< Pane >
attribute [source]
attribute [source]
index
attribute [source]
attribute [source]
index
kCommandSeparator : std::string_view
attribute [source]
attribute [source]
kCommandSeparator
kDefaultLineBytes : std::size_t
attribute [source]
attribute [source]
kDefaultLineBytes
kDefaultRetainedReplyBytes : std::size_t
attribute [source]
attribute [source]
kDefaultRetainedReplyBytes

How much of one reply a decoder holds, and how long a single line may grow before the stream is called broken.

A subprocess ends and gives its memory back; a connection does not, so the bound has to be in the decoder rather than in whatever reads it afterwards. The reply bound is the subprocess transport's capture limit, so the same call costs the same memory over either transport. The line bound has no subprocess equivalent: it is the point past which an unterminated line is evidence of a broken stream rather than a large answer.

kFormatEscape : std::string_view
attribute [source]
attribute [source]
kFormatEscape

A separator absent from every format name is not absent from every format value, which is the whole difficulty.

tmux rename-window 'a␞b` is accepted, and one such name used to make every window and pane listing on that server fail to split — data the caller never chose breaking reads of everything else.

So tmux escapes the separator before it can be mistaken for one. U+241B pairs with it and is escaped in turn, which is what makes the transform reversible: ␛S is a separator that was in the value and ␛E is an escape marker that was, and neither has a second reading.

kFormatSeparator : std::string_view
attribute [source]
attribute [source]
kFormatSeparator

tmux joins requested formats with a separator that cannot appear in a format name.

U+241E matches the Python implementation's default so both can read the same recorded output.

It is multi-byte, so every tmux this library starts is passed -u: a tmux that believes the terminal is not UTF-8 substitutes an underscore and no row splits at all.

kMinimumSupported : Version
attribute [source]
attribute [source]
kMinimumSupported

The oldest release this library supports, matching the Python package.

kNamedKeys : std::array
attribute [source]
attribute [source]
kNamedKeys

Named keys tmux accepts, taken from the table in its own key-string.c at the oldest supported release.

Function keys are generated rather than listed, and a single character is handled separately.

kSocketPathLimit : std::size_t
attribute [source]
attribute [source]
kSocketPathLimit
attribute [source]
attribute [source]
layout
attribute [source]
attribute [source]
name
attribute [source]
attribute [source]
name
attribute [source]
attribute [source]
name
pane_count : NumberFieldHandle< Window >
attribute [source]
attribute [source]
pane_count
attribute [source]
attribute [source]
path
attribute [source]
attribute [source]
path
attribute [source]
attribute [source]
pid
read_only : BoolFieldHandle< Client >
attribute [source]
attribute [source]
read_only
session_id : StringFieldHandle< Pane >
attribute [source]
attribute [source]
session_id
session_id : StringFieldHandle< Window >
attribute [source]
attribute [source]
session_id
session_name : StringFieldHandle< Client >
attribute [source]
attribute [source]
session_name
session_name : StringFieldHandle< Pane >
attribute [source]
attribute [source]
session_name
session_name : StringFieldHandle< Window >
attribute [source]
attribute [source]
session_name
terminal : StringFieldHandle< Client >
attribute [source]
attribute [source]
terminal
title : StringFieldHandle< Pane >
attribute [source]
attribute [source]
title
attribute [source]
attribute [source]
tty
attribute [source]
attribute [source]
tty
attribute [source]
attribute [source]
width
width : NumberFieldHandle< Pane >
attribute [source]
attribute [source]
width
attribute [source]
attribute [source]
width
window_count : NumberFieldHandle< Session >
attribute [source]
attribute [source]
window_count
window_id : StringFieldHandle< Pane >
attribute [source]
attribute [source]
window_id
zoomed : BoolFieldHandle< Window >
attribute [source]
attribute [source]
zoomed
LIBTMUX_ABI_NAMESPACE
constant [source]
constant [source]
LIBTMUX_ABI_NAMESPACE
LIBTMUX_NAMESPACE_BEGIN
constant [source]
constant [source]
LIBTMUX_NAMESPACE_BEGIN
LIBTMUX_NAMESPACE_END
constant [source]
constant [source]
LIBTMUX_NAMESPACE_END
LIBTMUX_REQUIRES_TMUX
constant [source]
constant [source]
LIBTMUX_REQUIRES_TMUX
LIBTMUX_SKIP_TMUX_DEFECT
constant [source]
constant [source]
LIBTMUX_SKIP_TMUX_DEFECT
all_of ( typename Entity , name : std::string , read : auto , predicate : auto ) typename Entity
function [source]
function [source]
all_of
any_of ( typename Entity , name : std::string , read : auto , predicate : auto ) typename Entity
function [source]
function [source]
any_of
capture_lines ( typename Text , Text && ) typename Text ( output : std::string_view ) std::vector< std::string_view >
functionoverload2 overloads [source]
functionoverload2 overloads [source]
capture_lines

The lines are views into the text, so text that dies at the semicolon takes them with it — and pane.capture() returns its output by value, which makes capture_lines(*pane.capture()) the natural thing to write and a use-after-free to run.

Deleted for an rvalue string only: an lvalue string converts as before, and so does a literal.

children_of ( typename Parent , typename Child , rows : const std::vector< Child > & , foreign_key : StringFieldHandle< Child > , key : StringFieldHandle< Parent > ) typename Parent ( typename Parent , typename Child , const std::vector< Child > && , StringFieldHandle< Child > , StringFieldHandle< Parent > ) typename Parent
functionoverload2 overloads [source]
functionoverload2 overloads [source]
children_of

Join two listings on the id one of them carries.

A relation predicate has to reach the related rows without running tmux, so the caller lists both kinds once and links them here. The result borrows the rows it was given, exactly as a filtered view does, so it must not outlive the listing it reads.

current_environment ( ) std::vector< std::string >
function [source]
function [source]
current_environment

Build and edit a NAME=VALUE block for a child process.

current_environment copies this process's; set_environment replaces any existing entry rather than appending; erase_environment removes every entry for the name.

decode_value ( begin : char * , size : std::size_t ) std::size_t
function [source]
function [source]
decode_value

Undo that escaping, in place.

Escaping only ever lengthens, so the decoded bytes fit where the encoded ones were: the write cursor never overtakes the read cursor, nothing moves, and nothing is allocated. Answers the decoded length.

An escape marker followed by anything else is left as written. Output this library asked for contains no such sequence, and failing on one would mean a recording could not carry a literal .

describe_running_tmux ( tmux_binary : const std::filesystem::path & = "tmux" ) std::string
function [source]
function [source]
describe_running_tmux

What tmux -V printed, verbatim, or "unknown".

erase_environment ( environment : std::vector< std::string > & , name : std::string_view ) void
function [source]
function [source]
erase_environment
escape_literal ( text : std::string_view ) std::string
function [source]
function [source]
escape_literal

Escape literal text for inclusion in a format string.

exactly_one ( Range : ReferenceRange , range : Range & ) ReferenceRange
function [source]
function [source]
exactly_one

exactly_one states that several is a caller error, and says which one.

Discussed in Filtering and querying, in practice

first ( Range : ReferenceRange , range : Range & ) ReferenceRange
function [source]
function [source]
first

first states that a caller tolerates extras; it never reports several.

format_request ( fields : std::span< const std::string_view > ) std::string
function [source]
function [source]
format_request

Build the format argument for one entity's fields, terminating every field so a trailing empty value is still a value rather than a missing column.

The two substitutions nest rather than run in sequence, because tmux applies the inner one to the raw value and the outer one to its result. In that order a value already holding the escape marker is neutralised before the separator pass can produce one; reversed, the two become indistinguishable.

#{s/…/…/:…} predates every tmux this library supports, and neither character is a regular-expression metacharacter.

Unconditional, rather than applied only to the fields that could carry a separator. Expanding the substitutions costs about 0.32us per row — a 61-row listing pays 19us, against a process launch of some milliseconds — and a per-field exemption list is a thing to get wrong later, once, silently.

is ( typename Entity , name : std::string , read : auto , predicate : auto ) typename Entity
function [source]
function [source]
is

An absent to-one link never satisfies is : a window with no active pane is not a window whose active pane runs an editor.

is_function_key ( name : std::string_view ) bool
function [source]
function [source]
is_function_key
is_key_name ( key : std::string_view ) bool
function [source]
function [source]
is_key_name

Accept a key with any number of C-, M-, or S- modifiers.

is_pane_id ( value : std::string_view ) bool
function [source]
function [source]
is_pane_id

Whether a value is written as an id, which is what decides that it needs no separator validation below — not whether tmux would resolve it.

x is an id by this test and no pane by tmux's, and both are right: it carries no separator, so composing it can only produce the caller's own mistake back.

is_session_id ( value : std::string_view ) bool
function [source]
function [source]
is_session_id
is_supported ( version : const Version & ) bool
function [source]
function [source]
is_supported
is_window_id ( value : std::string_view ) bool
function [source]
function [source]
is_window_id
library_version ( ) std::string_view
function [source]
function [source]
library_version

This package's own version, not tmux's.

literal_arguments ( text : std::string_view ) expected< std::vector< std::string >, KeyError >
function [source]
function [source]
literal_arguments

Send text exactly as written: the flag, the end of flags, and the text.

-- is part of the fragment rather than something a caller appends, because text beginning with a dash is read as another send-keys option without it and that is not a mistake worth making twice. It was made twice: this returned the flag and the text alone, Pane::send_text inserted the separator afterwards, and Chain::send_text did not — so the same text through the two spellings reached tmux as two different commands.

lookup_of ( name : std::string_view ) expected< StringOp, LookupParseError >
function [source]
function [source]
lookup_of

eq is the implicit lookup, matching Python's bare field=value.

An empty name reaches here only from a key that carried no separator at all; a key ending in one is refused before this is asked.

lower ( typename Entity , typename Sink , expr : const FilterExpr< Entity > & , sink : Sink & ) typename Entity
function [source]
function [source]
lower

A sink receives one call per node in prefix order.

Groups and negations are bracketed by begin/end so a sink never has to count operands itself.

matching ( typename Entity , expr : FilterExpr< Entity > ) typename Entity
function [source]
function [source]
matching

matching(expr) is a range adaptor closure so it composes with std views.

matching ( typename Entity , expr : FilterExpr< Entity > ) typename Entity ( typename Entity , field : BoolFieldHandle< Entity > ) typename Entity
functionoverload2 overloads [source]
functionoverload2 overloads [source]
matching

matching(expr) is a range adaptor closure so it composes with std views.

name_of ( op : StringOp ) std::string_view ( op : NumberOp ) std::string_view
functionoverload2 overloads [source]
functionoverload2 overloads [source]
name_of
none_of ( typename Entity , name : std::string , read : auto , predicate : auto ) typename Entity
function [source]
function [source]
none_of
pane_target ( session : std::string_view , window : std::string_view , pane : std::string_view ) expected< std::string, TargetError >
function [source]
function [source]
pane_target

A pane target is its id, or session:window.pane.

parent_of ( typename Child , typename Parent , rows : const std::vector< Parent > & , foreign_key : StringFieldHandle< Child > , key : StringFieldHandle< Parent > ) typename Child ( typename Child , typename Parent , const std::vector< Parent > && , StringFieldHandle< Child > , StringFieldHandle< Parent > ) typename Child
functionoverload2 overloads [source]
functionoverload2 overloads [source]
parent_of

The same join read the other way: the one row a child points at, or none.

parse ( notification : const Notification & ) ParsedNotification ( Notification && ) ParsedNotification
functionoverload2 overloads [source]
functionoverload2 overloads [source]
parse
parse_lookup ( typename Entity , term : std::string_view , fields : std::span< const StringFieldHandle< Entity > > ) typename Entity
function [source]
function [source]
parse_lookup

Parse one field[__lookup]=value term against a caller-supplied field table.

The value is taken verbatim after the first =, so a value containing = or __ survives unchanged; only the key is split.

parse_option ( line : std::string_view ) std::optional< OptionEntry >
function [source]
function [source]
parse_option

Parse one line.

Returns nullopt for a blank line so callers can feed raw output straight in.

parse_options ( output : std::string_view ) std::vector< OptionEntry >
function [source]
function [source]
parse_options
parse_version ( output : std::string_view ) expected< Version, VersionError >
function [source]
function [source]
parse_version

Parse the first line of tmux -V, with or without its trailing newline.

path_component ( name : std::string_view ) expected< std::string, TargetError >
function [source]
function [source]
path_component

Validate one path component.

Ids skip validation because they contain no separator by construction.

quantified ( typename Entity , name : std::string , quantifier : Quantifier , read : auto , predicate : auto ) typename Entity
function [source]
function [source]
quantified

To-many and to-one links take different accessors, so they get different builders rather than one that has to compile both shapes.

replay ( typename Sink , nodes : const LoweredExpression & , sink : Sink & ) typename Sink
function [source]
function [source]
replay

Replay an already-lowered child into a sink.

running_tmux ( tmux_binary : const std::filesystem::path & = "tmux" ) Version
function [source]
function [source]
running_tmux

Resolved once per distinct binary and cached.

A tmux that cannot be run or whose version cannot be parsed reports as the newest possible version, so version-gated tests run and fail rather than silently skipping.

same_entity_id ( left_id : std::string_view , left_session_id : std::string_view , right_id : std::string_view , right_session_id : std::string_view ) bool
function [source]
function [source]
same_entity_id
server_over ( backend : std::shared_ptr< const Backend > ) Server
function [source]
function [source]
server_over

Declared so the private constructor has exactly one way in.

Defined in a header this package does not install.

session_target ( session : std::string_view ) expected< std::string, TargetError >
function [source]
function [source]
session_target

A session target is its id, or its validated name.

set_environment ( environment : std::vector< std::string > & , name : std::string_view , value : std::string_view ) void
function [source]
function [source]
set_environment
socket_name_arguments ( name : std::string_view ) expected< std::vector< std::string >, SocketError >
function [source]
function [source]
socket_name_arguments

-L name: a single component resolved under the socket directory.

socket_path_arguments ( path : std::string_view ) expected< std::vector< std::string >, SocketError >
function [source]
function [source]
socket_path_arguments

-S path: used verbatim, so the address limit applies to it directly.

split_row ( line : std::string_view , fields : std::size_t , values : std::vector< std::string_view > & ) bool
function [source]
function [source]
split_row

Split one tmux output line into its field values.

The trailing separator emitted by format_request produces one empty tail element, which is dropped; a short or long row is reported rather than padded so a format-name typo cannot masquerade as an empty field.

to_flag ( text : std::string_view ) bool
function [source]
function [source]
to_flag

tmux renders flag formats as "1" or "0"; anything else is not the flag.

to_number ( text : std::string_view ) long long
function [source]
function [source]
to_number

tmux renders every value as text.

These read the three shapes it uses, and answer zero, false or the epoch for a value it did not render — which within the supported version range means tmux had nothing to say, not that the token was unknown.

to_string ( implementation : ServerImplementation ) std::string_view ( backend : BackendKind ) std::string_view ( feature : ServerFeature ) std::string_view ( error : CardinalityError ) std::string_view ( kind : FailureKind ) std::string_view ( status : DeliveryStatus ) std::string_view ( error : KeyError ) std::string_view ( kind : NotificationKind ) std::string_view ( error : SocketError ) std::string_view ( error : TargetError ) std::string_view ( error : VersionError ) std::string_view
functionoverload11 overloads [source]
functionoverload11 overloads [source]
to_string
to_time ( text : std::string_view ) std::chrono::sys_seconds
function [source]
function [source]
to_time
unexpected ( typename Error , error : Error && ) typename Error
function [source]
function [source]
unexpected

A factory rather than an alias: an alias template cannot deduce its argument, so unexpected(error) would stop compiling at every call site.

unquote ( value : std::string_view ) std::string
function [source]
function [source]
unquote

Undo the quoting tmux applies when it prints a value.

tmux picks one of four forms, and a reader that knows only one corrupts the rest: 'for an empty value; double quotes when the value contains any of #';${}; single quotes when it contains a double quote; and otherwise no quotes at all. Inside any of them the body is escaped the wayvisdoes it —\t,\n,\\,\ooo` for a byte with no printable form — and a leading tilde is escaped whether or not anything else is.

This is the inverse of tmux's own args_escape, so a value read here and written back is the value that was there.

variable ( name : std::string_view ) std::string
function [source]
function [source]
variable

Wrap a variable name as a substitution.

The name is not escaped: a name is chosen by the caller from tmux's format vocabulary, not built from data.

window_target ( session : std::string_view , window : std::string_view ) expected< std::string, TargetError >
function [source]
function [source]
window_target

A window target is its id, which needs no session, or session:window.

without_trailing_blanks ( lines : std::vector< std::string_view > ) std::vector< std::string_view >
function [source]
function [source]
without_trailing_blanks

Drop the blank rows a pane pads its height with, keeping blank lines that have content below them.

CommandObserver : std::function< void(std::string_view command, const CommandFailure *failure)>
typealias [source]
typealias [source]
CommandObserver

Told about every command, as it finishes.

There is otherwise no way to see what this library ran: a caller debugging a tmux interaction has only the failures, and nothing at all when things succeed. The command is rendered as tmux received it, with any argument marked sensitive replaced.

Synchronous calls invoke it on their caller's thread. Asynchronous calls invoke it only on the thread calling CommandRuntime::dispatch_ready. No internal lock is held; a shared observer must synchronise itself. Both callback arguments expire on return.

typealias [source]
typealias [source]
Event
expected : typename Value
typealias [source]
typealias [source]
expected
LoweredExpression : std::vector< LoweredNode >
typealias [source]
typealias [source]
LoweredExpression
Referenced : std::ranges::input_range
typealias [source]
typealias [source]
Referenced
RelatedMany : typename Entity
typealias [source]
typealias [source]
RelatedMany

The related entity is whatever the accessor yields, so a bare flag field can stand in for a predicate here exactly as it does in matching.

RelatedOne : typename Entity
typealias [source]
typealias [source]
RelatedOne
unexpected_t : typename Error
typealias [source]
typealias [source]
unexpected_t
Esc

Type to search.