Server.panes
Every pane on the server.
Source and package
-
Description#
Save this complete program as
panes.ts. With Bun 1.4.2 or newer, tmux 3.2a or newer, andlibtmuxinstalled, runbun run panes.ts. It creates and stops a private tmux server. A failed operation or cleanup exits with an error; a cleanup error names the retained socket directory.Examples#
import { strict as assert } from "node:assert";import { mkdtemp, readdir, rm } from "node:fs/promises";import { tmpdir } from "node:os";import { join } from "node:path";import { Server, PaneDirection } from "libtmux";const directory = await mkdtemp(join(tmpdir(), "ltx-example-"));const server = new Server({socketPath: join(directory, "tmux.sock"),configFile: "/dev/null",timeoutMs: 5_000,});const failures: unknown[] = [];try {const session = await server.newSession({name: "work",windowName: "editor",shellCommand: "cat",});const pane = session.panes.one();await pane.split({ direction: PaneDirection.Below, shellCommand: "cat" });const panes = await server.panes();assert.equal(panes.count(), 2);const active = panes.where({ active: true });assert.equal(active.count(), 1);console.log("panes:", panes.count(), "active:", active.count());for (const item of panes) {assert.equal(item.session?.name, "work");assert.equal(item.window?.name, "editor");console.log("location:", item.session?.name, item.window?.name);}} catch (error) {failures.push(error);} finally {try {if ((await readdir(directory)).includes("tmux.sock")) await server.kill();await rm(directory, { recursive: true });} catch (error) {failures.push(new Error(`Cleanup failed; inspect ${directory}`, { cause: error }));}}if (failures.length > 0) throw new AggregateError(failures, "Example failed");
Guides#
Pages that discuss panes.
In other ports#
List the server's panes
| Language | Equivalent |
|---|---|
| Python | libtmux |
| Ruby | Lib |
| Lua | libtmux |
| PowerShell | Lib Use the -Server parameter set to acquire panes across the server. |
| Julia | Lib panes with a Snapshot reads every captured physical pane. Use paneoccurrences for session placements. |
| Elixir | Lib Returns a Selection of every captured physical pane without contacting tmux. |
| Rust | server |
| Go | tmux |
| Java | io |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| F# | Lib Builds a deferred pane query on the shared .NET LibTmux.Server. Query.list acquires panes across that server. |
| C++ | libtmux:: |
| Swift | Server |