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.

config.Workspace.from_file

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

pub fn from_file(path: impl AsRef<Path>) -> Result< Self, ConfigError >

Read and parse one workspace file, as tmuxp load does.

Description#

Everything Self::from_yaml() says holds, except that a start directory beginning with . and inheriting none is relative to the file's directory. JSON is read too, as the YAML it is a subset of.

Errors

Returns ConfigError::Read when the file cannot be read, and otherwise what Self::from_yaml() returns.

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: ./\nwindows: []\n")?;
let workspace = Workspace::from_file(&file)?;
assert_eq!(workspace.start_directory.as_deref(), Some(project.path()));
Parameters
Esc

Type to search.

Reference previewOpen reference