Core Library0.xConcepts

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.

MoreLess about this notice
Edit this page on GitHub

Filtering and queries

Use a collection filter to find matching sessions, windows, or panes. Use an exactly-one lookup when your next operation requires a single target.

  • Filtering returns a collection; exactly-one lookup checks the result count. A filter returns zero or more matches. An exactly-one operation returns one object or reports a missing or ambiguous match.

  • Choose where to filter. Filter a snapshot in your program when you need several queries over the same data. A tmux format filter can reduce the rows returned by a live read. The cost depends on the data and queries you need.

Typed and local filters

Compose FilterExpr values with &&, ||, and !. For example, pane::command.starts_with("nv") && pane::active is valid, while pane::active.starts_with("x") fails to compile.

Use libtmux::matching to apply a typed filter to a captured collection. Iterating that filtered range reads the captured objects in memory.

Result counts

libtmux::exactly_one distinguishes a missing match from an ambiguous one. For versions with a runnable reference example, its Example section shows the complete window query, build commands, and expected output.

Borrow or copy a match

libtmux::first and libtmux::exactly_one borrow from an lvalue range. Keep the range and its backing storage alive while using the match. Check the first signature in the selected version’s reference. Pointer results use nullptr for a missing match. Versions returning an optional use an empty optional.

libtmux::first_owned copies the first match into an optional value. libtmux::exactly_one_owned copies the unique match or returns a cardinality error. The owned forms also accept temporary views.

In source revisions with borrowing diagnostics, compilers implementing C++26 deleted-function messages can name the owner to keep when a temporary is rejected. Use the querying and filtering guide to choose a target and handle the result.

Esc
Search in

Type to search.

Reference previewOpen reference