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

config.Workspace.from_yaml

Rust
  • Python Unavailable
  • Ruby Unavailable
  • Lua Unavailable
  • TypeScript Unavailable
  • Rust
  • Go Unavailable
  • Java Unavailable
  • .NET Unavailable
  • C++ Unavailable
  • Swift Unavailable

API reference · Markdown

config.Workspace.from_yaml ( source : &str ) → Result<Self, ConfigError>
method [source]
method [source]
config.Workspace.from_yaml

Parse one workspace from tmuxp-style YAML.

This accepts the shape tmuxp uses for the parts a builder needs. It is deliberately not a full tmuxp implementation: unknown keys are ignored rather than rejected, so a richer tmuxp file still loads.

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.

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);

Discussed in Rust workspace internals , Use the Rust workspace builder , Rust workspace builder behavior , Rust workspace builder API

Esc

Type to search.