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:
$ cargo add tmux-workspaceThe runnable example also uses libtmux’s isolated test server.
Enable its test-support feature:
$ cargo add libtmux --features test-supportAdd the Tokio runtime used by the example:
$ cargo add tokio --features macros,rt-multi-threadDescribe the sessionLink to section
Save this description as dev.yaml:
session_name: devwindows: - 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.