Core Library0.xConcepts

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.

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:

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.

Building one declaratively

These packages read or build workspace configurations based on tmuxp:

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

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

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.

Reference previewOpen reference