builder.applyWorkspace
- async function applyWorkspace( server: Server, workspace
Input : WorkspaceInput , options: ApplyWorkspace = {}, ): Promise<Session>Options -
Build a workspace into a real tmux session, or reconcile one that exists.
Description#
tmux gives every new session a window and every new window a pane, so the first window and first pane of each level are adopted rather than created. Creating them anyway is the classic workspace-builder bug that leaves an empty leading window behind.
What this reconciles is topology: which windows exist, in what order, under what names, with how many panes, under which layout. It is safe to apply twice and the second run does not duplicate anything. It is deliberately not a process supervisor — see
CommandPolicy— and it does not unset options a previous version of the file had set, because tmux cannot say which of an option's current values this file is responsible for.This is not the builder behind the
tmux-workspacecommand. The two are separate implementations of one idea and they answer differently: this one converges a session that exists, while the CLI compares it against the document and refuses when they disagree. The document language differs too — the schema here is strict, soenvironment,before_script,window_index,suppress_history,x-keys and the CLI's other fields are rejected. A file written for the CLI is not necessarily one this accepts.- Parameters
-
-
options={}(ApplyWorkspace ) #Options
- Raises
-
-
ZodError – when the workspace does not satisfy the strict config schema.
-
Type
Error – when operation options, layouts or version replies are invalid. -
Workspace
Apply – when tmux fails after applying may have started.Error
-
Guides#
Pages that discuss applyWorkspace.
- Concepts
In other ports#
Build a session from a workspace description
| Language | Equivalent |
|---|---|
| Python | tmuxp |
| Ruby | Lib |
| PowerShell | Lib Applies the exact reviewed -Plan after PowerShell confirmation. -WhatIf previews without applying it; application is detached. |
| Julia | Lib Applies a prepared WorkspacePlan on an explicit Server, detached and under one deadline. Existing session names fail unless reuse is explicit. |
| Rust | src |
| Go | workspace |
| Java | io |
| C# | Lib |
| C++ | libtmux:: |
| Swift | Workspace |
No equivalent is recorded in Lua, Elixir, Kotlin, Scala or F#.