Rust
Rust
Drive a real tmux from Rust.
libtmux
Install
$ cargo add libtmuxQuickstart
use libtmux::test::TestServer;
#[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error>> { // Runs for real. `TestServer` is an isolated tmux on its own socket under // `/tmp/libtmux-rs-test/`, torn down at the end. Your own code says // `let server = libtmux::Server::new()?;` instead; nothing else changes. let guard = TestServer::new().await?; let server = guard.server();
let session = server.new_session("work").await?; let window = session.new_window("editor").await?; let pane = window.active_pane().await?.expect("a window has a pane");
pane.send_line("echo hello").await?;
for line in pane.capture().await? { println!("{}", line.to_string_lossy()); }
guard.shutdown().await?; Ok(())}The crate README's own "Drive tmux" section, verbatim — doctested in full via #![doc = include_str!("../README.md")], so `cargo test --doc` compiles and runs this exact block against a throwaway tmux.
API References
Official reference
Every public Rust symbol, extracted from source on libtmux.org and cross-linked to the other seven ports.
docs.rs documentation
docs.rs builds and hosts every published crate version automatically, and it is where Rust developers already look. We ship the same rustdoc theme flags via [package.metadata.docs.rs] so the page carries our palette.
Read on
Topics
Deep dives into one subject at a time, in Rust: architecture, traversal, options and hooks.
Guides
Task-oriented walkthroughs in Rust — install tmux, then the round trip every real program starts from.
Examples
The same concrete tasks worked through in Rust, with each snippet checked by the port's own tests.
Concepts
The domain model every port shares — the object hierarchy, transports and filtering.