Core LibraryunreleasedGuides

Choose documentation 2

latest

Current version

latest
English

Unreleased libtmux has not been released. Its API may change during development. This site's structure and URLs may change too.

Run a complete capability example

Each program creates a private tmux workspace, performs one task, verifies the result and closes its clients. Copy the whole file into a Dune project or run it from this checkout after installation.

The programs use a minimal tmux configuration that makes their private daemon exit when its last client detaches. They accept an optional tmux binary, not a borrowed server socket. Their setup uses the public workspace API; the task uses the client API. The Eio example starts its scheduler after setup and subscribes before sending the bytes it observes.

For a separate project, save a program as main.ml and use these Dune libraries:

(executable
(name main)
(libraries libtmux libtmux-workspace libtmux-unix unix))

The watch program also needs libtmux-eio and eio_main. The installation guide supplies the project and switch setup.

TaskComplete programExpected outcome line
Start a private server and its first sessionBootstrapbootstrapped: 1 session, 1 window, 1 pane
Navigate sessions, shared windows and panesGraphgraph: 2 sessions, 2 windows, 3 links, 2 panes
Observe future bytes concurrentlyWatchobserved: changed
Send literal input and EnterKeyssent: literal: $HOME; #{pane_id}
Rename a window and retain the old observationRenamerenamed: editor-main
Create a window and recapture its nameCreatecreated: logs
Move a window to another session’s indexMovemoved: build at 7
Apply and verify horizontal pane geometryLayoutlayout: 3 horizontal panes

All programs print their temporary socket path before the outcome. The bootstrap walkthrough explains the missing-endpoint precondition and ownership of the resulting client:

Terminal window
$ opam exec -- dune exec examples/showcase_bootstrap.exe -- tmux

Run the graph example; it traverses the snapshot after the client and daemon close:

Terminal window
$ opam exec -- dune exec examples/showcase_graph.exe -- tmux

Observe future output with an application-owned Eio switch:

Terminal window
$ opam exec -- dune exec examples/showcase_watch.exe -- tmux

Send a literal string containing shell and tmux format characters:

Terminal window
$ opam exec -- dune exec examples/showcase_send_keys.exe -- tmux

Rename the editor window:

Terminal window
$ opam exec -- dune exec examples/showcase_rename_window.exe -- tmux

Create a separate logs window:

Terminal window
$ opam exec -- dune exec examples/showcase_create_window.exe -- tmux

Move a build window to index 7 in another session:

Terminal window
$ opam exec -- dune exec examples/showcase_move_window.exe -- tmux

Split a window and apply an even horizontal layout:

Terminal window
$ opam exec -- dune exec examples/showcase_layout.exe -- tmux

These examples support tmux 3.3a–3.8 on the qualified Linux environment. The native CI job executes their real entry points on 3.3a and 3.8, using a separate installation and Dune project. A nonzero exit, missing exact outcome line, leftover directory or surviving owned process fails the run. showcase.json records the whole files, commands, expected lines, tmux floor, workflow, job and runner.

Sending keys confirms tmux accepted input. The rendered-text example observes the resulting screen; it does not wait for an arbitrary application’s exit code. A future-byte subscription has no historical capture barrier. See control outcomes and streaming for those contracts.

Esc

Type to search.

Reference previewOpen reference