Workspace ManagerconceptInternals

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.

Edit this page on GitHub

Use the Rust workspace builder

tmux-workspace 0.1.2 · 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 session

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 creating

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 layout

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.

Reference previewOpen reference