Workspace ManagerconceptInternals

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

Use the Java workspace builder

libtmux-workspace 0.1.2-SNAPSHOT · Source

Add the workspace module to a Java 21 project. The BOM selects compatible libtmux modules:

build.gradle.kts
dependencies {
implementation(platform("io.github.libtmux:libtmux-bom:0.1.0"))
implementation("io.github.libtmux:libtmux-workspace")
}

Install tmux on the host before running the builder.

Create and inspect

This program builds on a dedicated socket, prints the resulting session name, and removes the session after inspection. Save it in your application’s Java sources and run it through your existing Gradle application task.

import io.github.libtmux.Server;
import io.github.libtmux.ServerEndpoint;
import io.github.libtmux.Session;
import io.github.libtmux.workspace.Workspace;
import io.github.libtmux.workspace.WorkspaceBuilder;
import java.util.UUID;
public class WorkspaceGuide {
public static void main(String[] args) {
Workspace workspace = WorkspaceBuilder.parse("""
session_name: guide
windows:
- window_name: editor
panes:
- echo ready
- echo ready
""");
try (Server server = Server.builder()
.endpoint(ServerEndpoint.namedSocket(
"workspace-" + UUID.randomUUID()))
.build()) {
Session session = WorkspaceBuilder.build(server, workspace);
try {
System.out.println(session.name());
} finally {
session.kill();
}
}
}
}

Read a file

Use WorkspaceBuilder.read(Path) to parse YAML from disk. It reports file read failures as UncheckedIOException; invalid configuration raises IllegalArgumentException. Handle those before calling build.

For an application that keeps the workspace running, keep the session rather than calling kill. Closing the Java server handle releases its transport; it does not serve as workspace removal.

If construction fails, inspect the exception and its suppressed cleanup failures. Topics describes the builder’s cleanup scope.

Dependency and workspace usage; Server lifetime API.

Esc

Type to search.

Reference previewOpen reference