Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

Use the Rust workspace builder

Edit this page on GitHub

tmux-workspace 0.1.0-alpha.12 · Source

Build a workspace by parsing its YAML and passing it to WorkspaceBuilder. Install tmux first, then add the crate to a Rust project:

Terminal window
$ cargo add tmux-workspace

The runnable example also uses libtmux’s isolated test server. Enable its test-support feature:

Terminal window
$ cargo add libtmux --features test-support

Add the Tokio runtime used by the example:

Terminal window
$ cargo add tokio --features macros,rt-multi-thread

Describe the sessionLink to section

Save this description as dev.yaml:

session_name: dev
windows:
- window_name: editor
panes: [/bin/sh, /bin/sh]

In an async application, read the file with std::fs::read_to_string, parse it with Workspace::from_yaml, and construct WorkspaceBuilder::new(&server) using your libtmux server handle. build(&workspace).await returns the newly created session.

Preview before creatingLink to section

Call plan(&workspace) on the builder before execution. Iterate over the plan’s preview() if you need to show the commands to an operator. Planning itself does not test current session-name availability or execute commands.

If the requested session already exists, choose another name or explicitly remove a session you own. Do not treat the error as a request to adopt it. After a partial build failure, inspect the server before retrying.

Save a live layoutLink to section

Use freeze(&session).await to produce a new Workspace, then write its to_yaml() output to a file. Review the resulting command descriptions before loading the file later. Topics explains what the export can recover.

Crate usage and dependencies

Esc

Type to search.