Window.panes
This link's panes, in tmux's order. A pure read of the capture.
Source and package
- Qualified name
-
io.github .libtmux .Window. panes - Package
- io.github.libtmux
- Declared in
Window- Distribution
- io.github.libtmux:libtmux
- Source
- libtmux/src/main/java/io/github/libtmux/Window.java
- Other languages
- Perlmethod Erlangfunction PowerShellcmdlet Juliafunction Elixir Haskell Common Lispfunction PythonRuby Lua TypeScriptRustGoC#C++SwiftKotlinScalaOCamlfunction F#function Clojurefunction
-
Examples#
List all panes, then the panes captured for one window. Use JDK 25, Gradle 9 or newer, and tmux 3.3a or newer on Linux, with
/bin/catand/bin/shavailable. In an empty directory, save this consumer setup assettings.gradle.kts:rootProject.name = "api-example"Save this consumer setup as
build.gradle.kts. It depends on the 0.1.2 release from Maven Central:plugins {application}repositories { mavenCentral() }dependencies {implementation("io.github.libtmux:libtmux:0.1.2")}java { toolchain { languageVersion.set(JavaLanguageVersion.of(25)) } }application { mainClass.set(providers.gradleProperty("exampleMain")) }Save this consumer setup as
gradle.properties: View sourceorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=768m -Dfile.encoding=UTF-8kotlin.daemon.jvmargs=-Xmx2gorg.gradle.workers.max=2Save this launcher as
run.sh. It creates and stops a private tmux server, including after program failure. A shutdown failure retains its socket directory and exits unsuccessfully. View source#!/bin/shset -euif [ "$#" -eq 0 ]; thenprintf 'Usage: sh run.sh program [arguments...]\n' >&2exit 2fibinary=$(command -v "${TMUX_BIN:-tmux}")root=${API_RUN_ROOT:-/tmp/libtmux-java-dev}# A client that names no socket follows TMUX or LIBTMUX_SOCKET*, and otherwise lands on the default# socket under TMUX_TMPDIR. The program gets none of them, and a TMUX_TMPDIR of its own below.unset TMUX TMUX_PANEfor name in $(env | sed -n 's/^\(LIBTMUX_SOCKET[A-Za-z0-9_]*\)=.*/\1/p'); dounset "$name"donemkdir -p "$root"directory=$(mktemp -d "$root/api.XXXXXX")tmpdir=$(mktemp -d "$root/tmpdir.XXXXXX")socket="$directory/tmux.sock"config="$directory/tmux.conf"serves() {"$binary" -S "$1" display-message -p '#{pid}' >/dev/null 2>&1}# Stops the server on the socket, then waits for it to stop answering.stop() {"$binary" -S "$1" kill-server || return 1attempts=0while serves "$1" && [ "$attempts" -lt 60 ]; dosleep 0.05attempts=$((attempts + 1))done! serves "$1"}cleanup() {status=$?trap - 0 HUP INT TERM PIPE# A closed output must not end the cleanup, whose messages are the only thing left to write.trap '' PIPEset +estuck=left=if [ -S "$socket" ] && serves "$socket" && ! stop "$socket"; thenstuck="$stuck tmux.sock"fi# Every socket anywhere under either directory, without following links. Only one a server answers# on is a leak; the runner's own is expected to be there.old_ifs=$IFSIFS=''set -ffor candidate in $(find "$tmpdir" "$directory" -type s 2>/dev/null); do[ "$candidate" = "$socket" ] && continueserves "$candidate" || continuecase "$candidate" in"$tmpdir"/*) name=${candidate#"$tmpdir"/} ;;*) name=${candidate#"$directory"/} ;;esacleft="$left $name"stop "$candidate" || stuck="$stuck $name"doneset +fIFS=$old_ifsif [ -n "$stuck" ]; thenprintf 'tmux still answers on%s after kill-server; kept %s and %s under the runner root\n' \"$stuck" "${directory##*/}" "${tmpdir##*/}" >&2exit 1firm -rf "$directory" "$tmpdir" || exit 1if [ -n "$left" ]; thenprintf 'The program left a tmux server running:%s\n' "$left" >&2exit 1fiexit "$status"}trap cleanup 0trap 'exit 1' HUP INT TERM PIPE# A default socket path longer than this does not fit in sun_path.default_socket="$tmpdir/tmux-$(id -u)/default"if [ "$(printf '%s' "$default_socket" | wc -c)" -gt 100 ]; thenprintf 'API_RUN_ROOT is too long for a tmux socket\n' >&2exit 1fiTMUX_TMPDIR=$tmpdirexport TMUX_TMPDIRprintf 'set-option -g default-shell /bin/sh\n' > "$config""$binary" -S "$socket" -f "$config" new-session -d -s work-one -n editor /bin/cat"$binary" -S "$socket" split-window -h -t '=work-one:editor' /bin/cat"$binary" -S "$socket" new-window -d -t '=work-one' -n logs /bin/cat"$binary" -S "$socket" new-session -d -s work-two -n editor /bin/cat"$@" "$binary" "$socket" "$config""$binary" -S "$socket" has-session -t '=work-one'"$binary" -S "$socket" has-session -t '=work-two'Save this complete program as
src/main/java/ListPanes.java. It opens an ordinary client for the launcher's server; closing the client releases its transport. View sourcepackage io.github.libtmux.examples.api.java;import io.github.libtmux.Server;import io.github.libtmux.ServerConfig;import io.github.libtmux.ServerEndpoint;import java.nio.file.Path;/** List all panes, then the panes captured for one window. */public final class ListPanes {private ListPanes() {}public static void main(String[] args) {try {if (args.length != 3) {throw new IllegalArgumentException("expected: tmux-binary socket-path config-file");}var config = ServerConfig.builder().binary(args[0]).endpoint(ServerEndpoint.socketPath(Path.of(args[1]))).configFile(Path.of(args[2])).build();try (Server server = Server.open(config)) {System.out.println("panes=" + server.panes().size());var session = server.session("work-one").orElseThrow();var window = session.windows().stream().filter(item -> item.name().equals("editor")).findFirst().orElseThrow();System.out.println("window-panes=" + window.panes().size());}} catch (Exception error) {if (error instanceof InterruptedException) Thread.currentThread().interrupt();System.err.println("Example failed: " + error.getMessage());System.exit(1);}}}Build the minimal consumer with Gradle and run the saved program with the private fixture. An operation or cleanup error makes the command exit unsuccessfully:
Terminal window $ gradle --console=plain --quiet installDist -PexampleMain=io.github.libtmux.examples.api.java.ListPanes && \sh run.sh build/install/api-example/bin/api-exampleExpected output:
panes=4window-panes=2
Guides#
Pages that discuss panes.
In other ports#
List a window's panes
| Language | Equivalent |
|---|---|
| Python | libtmux |
| Ruby | Lib |
| PowerShell | Lib Use the -Window parameter set to acquire panes in one window. |
| Julia | Lib panes with a captured WindowSnapshot reads panes in that window; missing coverage is an error. |
| Erlang | tmux Pass panes, a captured physical window and its snapshot for a local relationship read. |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| Common Lisp | libtmux: panes traverses a captured window without contacting tmux. |
| TypeScript | window |
| Rust | window |
| Go | tmux |
| Clojure | libtmux Traverses one capture locally. It does not issue a list-panes command. |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| F# | Lib Builds a deferred pane query from one LibTmux.Window and its server. Query.list acquires panes scoped to that window ID. |
| C++ | libtmux:: |
| Swift | Snapshot |
| OCaml | Libtmux Reads captured panes in one global window without I/O. |
| Perl | Lib Reads this physical window’s captured panes without I/O. |
No equivalent is recorded in Lua or Elixir.