-
One workspace: a session and the windows it should contain.
Discussed in Use the Rust workspace builder , Rust workspace builder behavior , Rust workspace builder API
In other ports Describe a workspace as data
- Python tmuxp uses configuration dictionaries rather than a dedicated workspace value type
- TypeScript
config.Workspace - Go
workspace.Workspace - Java
io.github.libtmux.workspace.Workspace.Workspace - .NET
LibTmux.Workspace.WorkspaceFile - C++
libtmux::workspace::Workspace - Swift
Workspace
Members
-
The session name to create.
Discussed in Format-token fields
-
A working directory inherited by windows that do not set their own.
-
Environment variables to set on the session.
-
Session options to apply once the session exists.
-
Global options to apply once the session exists.
- shell_command_before : Vec<ShellCommand>
-
Commands run in every pane before its own, in order.
-
Whether to keep pane commands out of the shell's history.
A file that does not say reads as
true, as in tmuxp.
- windows : Vec<WindowConfig>
-
The windows to create, in order.
-
Keys this parser recognized but does not act on.
Reported rather than dropped, so a caller can say what part of a file was ignored instead of leaving the difference to be discovered later.
- from_yaml ( source : &str ) Result<Self, ConfigError>
-
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$NAMEor${NAME}from this process's environment in names, start directories, andenvironmentand 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 withis relative to the one it inherits, or to the current directory at the top:Self::from_fileuses 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: demowindows:- window_name: editorpanes:- 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
-
Read and parse one workspace file, as
tmuxp loaddoes.Everything
Self::from_yamlsays holds, except that a start directory beginning withand inheriting none is relative to the file's directory. JSON is read too, as the YAML it is a subset of.Errors
Returns
ConfigError::Readwhen the file cannot be read, and otherwise whatSelf::from_yamlreturns.Examples
use tmux_workspace::Workspace;let project = tempfile::tempdir()?;let file = project.path().join(".tmuxp.yaml");std::fs::write(&file, "session_name: project\nstart_directory: ./\n")?;let workspace = Workspace::from_file(&file)?;assert_eq!(workspace.start_directory.as_deref(), Some(project.path()));
-
Render this workspace as tmuxp-style YAML.
Emits the keys this crate acts on and nothing else, so a document that came from
Self::from_yamland back may be shorter than it started: what is dropped is whatunsupported_keysalready named.Examples
use tmux_workspace::Workspace;let workspace = Workspace::from_yaml("session_name: demowindows:- window_name: editorpanes: [htop]",)?;// What it writes, it can read.assert_eq!(Workspace::from_yaml(&workspace.to_yaml())?, workspace);Discussed in Use the Rust workspace builder , Rust workspace builder behavior , Rust workspace builder API