tmuxtmuxConcepts

Choose documentation 1

latest

tmux manual version

Latest (3.7c) 3.7c 3.2a
English

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

Edit this page on GitHub

Workspaces

A workspace arranges windows and panes for a task, such as editing code, running a development server, and following logs. Build it with the object API when the layout depends on program logic. Use a declarative builder when you want to store the layout in a configuration file, such as tmuxp YAML or JSON.

Building one imperatively

Create a window, split it into panes, apply a layout, and send each pane its command:

def create_dev_workspace(session, name='dev'):
window = session.new_window(window_name=name, attach=False)
window.resize(height=50, width=160)
main_pane = window.active_pane
terminal_pane = main_pane.split(size='30%')
log_pane = terminal_pane.split(direction=PaneDirection.Right)
return {'window': window, 'main': main_pane,
'terminal': terminal_pane, 'logs': log_pane}

A split creates a pane; direction and size control its placement. Applying a layout rearranges existing panes while their processes continue running. tmux provides even-horizontal, even-vertical, main-horizontal, main-vertical, and tiled layouts.

Choose detached creation when the user's current window should retain focus. Splits and resizes issue tmux commands; Control mode vs one-shot covers their transport costs and batching.

attach=False keeps a newly created window in the background.

Building one declaratively

These packages read or build workspace configurations based on tmuxp:

Python

tmuxp loads a workspace configuration and creates its sessions, windows, and panes. See Workspace Manager for its configuration and CLI.

TypeScript

@libtmux/workspace applies a workspace configuration through applyWorkspace. Pass the server and a configuration containing session_name and windows.

Go

The workspace package loads tmuxp-shaped workspace configurations. See Workspace Manager for the supported fields and CLI.

Rust

The tmux-workspace crate loads tmuxp-shaped configurations. See Workspace Manager for the supported fields and CLI.

Java

libtmux-workspace supports the tmuxp configuration fields needed to describe a workspace. See Workspace Manager for the supported configuration and CLI.

C#

LibTmux.Workspace reads tmuxp YAML. See Workspace Manager for configuration fields and the CLI.

Swift

TmuxWorkspace accepts configurations written in Swift, JSON, or YAML. YAML support requires the YAMLWorkspaces trait.

TypeScript's applyWorkspace applies a desired configuration. Applying the same configuration again reuses its existing objects:

await applyWorkspace(server, {
session_name: "api",
windows: [
{ window_name: "editor", panes: ["vim", "git status"] },
{ window_name: "server", panes: [{ shell_command: "bun dev", focus: true }] },
],
});

Cleaning up

Window and Session context managers kill their objects on block exit, including when the block raises: Use a named error result in the enclosing function so deferred cleanup can return its own failure. Give cleanup a fresh, bounded context: An ownership scope kills its session when await using exits:

with session.new_window(window_name='temp-window') as temp_win:
pane = temp_win.active_pane
pane.send_keys('echo "temporary workspace"')
# window is gone here, even if the block raised

See Context managers for cleanup support in each port. Use explicit kill methods when the handle does not provide scope-based cleanup.

Esc

Type to search.