Examples
Attach and send keys
Find a session, send a command, and read its output.
Capture pane output
Read a pane's screen and wait for output to appear.
Build a workspace from a file
Create a session, windows, and panes from configuration.
Use these programs to send input, capture output, and build a workspace. Each example page includes its source and test coverage. Check those details before adapting an excerpt into a standalone program.
Source and verification¶
Port repositories use the following checks for their source examples. This site reads or copies those examples; a successful site build alone does not execute them:
Python¶
The test configuration includes README.md and src/libtmux/ in its
doctest collection. The >>> examples run against isolated tmux sessions.
TypeScript¶
scripts/check-doc-runnable.ts checks that a block tagged with its
example source matches that file line for line. The integration suite
executes the source program.
Go¶
go generate ./tmux refreshes documented regions from matching source
regions under examples/. CI checks that those generated excerpts are current.
Rust¶
The library includes its README as a crate doc comment.
cargo test --doc compiles and runs its executable Rust code blocks.
Java¶
./gradlew :docs-tests:test compiles executable Java blocks in READMEs
and guides against the library artifacts, then runs them against tmux through
libtmux-junit5.
C#¶
sync_snippets.py --check checks excerpts from tested [Example]
methods. ReadmeExampleTests also compiles and executes blocks marked
csharp run.
C++¶
tools/docs/check_readme.py checks that README examples match their
source regions in examples/05-readme.cpp. CTest builds and runs that program.
Swift¶
Scripts/check_examples.py checks that README examples match sources
under Examples/Sources/. swift test --package-path Examples compiles
those examples through the public products.
See Testing with libtmux for the fixture each of those test suites runs against, and each example page for the exact file a given snippet was quoted from.