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.

builder.applyWorkspace

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-workspace command. 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, so environment, 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
Raises
  • ZodError – when the workspace does not satisfy the strict config schema.

  • TypeError – when operation options, layouts or version replies are invalid.

  • WorkspaceApplyError – when tmux fails after applying may have started.

Guides#

Pages that discuss applyWorkspace.

Concepts

In other ports#

Build a session from a workspace description

Equivalents of Build a session from a workspace description in other languages
Language Equivalent
Python tmuxp.workspace.builder.ClassicWorkspaceBuilder.build
Ruby LibTmux::Workspace::Plan#apply
PowerShell LibTmux.Workspace\Invoke-TmuxWorkspace Applies the exact reviewed -Plan after PowerShell confirmation. -WhatIf previews without applying it; application is detached.
Julia LibTmuxWorkspace.apply Applies a prepared WorkspacePlan on an explicit Server, detached and under one deadline. Existing session names fail unless reuse is explicit.
Rust src.WorkspaceBuilder.build
Go workspace.Build
Java io.github.libtmux.workspace.WorkspaceBuilder.build
C# LibTmux.Workspace.WorkspaceBuilder.BuildAsync
C++ libtmux::workspace::build
Swift WorkspaceBuilder.build(_:on:)

No equivalent is recorded in Lua, Elixir, Kotlin, Scala or F#.

Esc

Type to search.

Reference previewOpen reference