Workspace ManagerconceptAPI reference

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.

MoreLess about this notice

Concept example A working example of the core library. It can change without notice. What concept means

config.Workspace.from_yaml

This type appears in public signatures. It is not a package entry point.

pub fn from_yaml(source: &str) -> Result<Self, ConfigError>
Errors
Returns an error when the document is not valid YAML, does not hold exactly one workspace, or is missing session_name. Every error except the document count names the line and column to look at.doc comment · parse.rs:37

Parse one workspace from tmuxp-style YAML.

Description

This accepts the shape tmuxp uses for the parts a builder needs. A key this parser does not act on is recorded rather than rejected, so a richer tmuxp file still loads; Self::from_yaml_strict() refuses one instead.

As tmuxp does, it expands ~ and $NAME or ${NAME} from this process's environment in names, start directories, and environment and option values, leaving an unset variable as written; commands are typed as written, for the pane's shell to expand. A start directory that begins with . is relative to the one it inherits, or to the current directory at the top: Self::from_file() uses the file's directory instead.

Errors

Returns an error when the document is not valid YAML, does not hold exactly one workspace, or is missing session_name. Every error except the document count names the line and column to look at.

Parameters

Examples

use tmux_workspace::Workspace;
let workspace = Workspace::from_yaml(
"
session_name: demo
windows:
- window_name: editor
panes:
- echo one
- shell_command: echo two
",
)?;
assert_eq!(workspace.session_name, "demo");
assert_eq!(workspace.windows.len(), 1);
assert_eq!(workspace.windows[0].panes.len(), 2);

Guides

task material

Pages that discuss from_yaml.

Esc
Search in

Type to search.

Reference previewOpen reference