Window.panes
This link's panes, in tmux's order. A pure read of the capture.
Source and package
- Module
- io.github.libtmux.kotlin
- Declared in
- Window
- Package
- io.github.libtmux:libtmux-kotlin
- Source
- libtmux-kotlin/src/main/kotlin/io/github/libtmux/kotlin/Window.kt
- Other languages
- PythonRuby Lua TypeScriptRustGoJavaC#C++SwiftScala F#
-
Examples#
List all panes, then the panes captured for one window. Use JDK 25, Git, and tmux 3.2a through 3.7c on Linux, with /bin/cat and /bin/sh available. In an empty directory, fetch the documented library revision:
Terminal window $ git clone https://github.com/libtmux/libtmux-java.git libtmux-source && \git -C libtmux-source checkout f56392b5d9bc7f1f9c1631842333fb90f3d82d40Save this consumer setup as settings.gradle.kts: View source
rootProject.name = "api-example"includeBuild("libtmux-source")Save this consumer setup as build.gradle.kts: View source
plugins {kotlin("jvm") version "2.4.10"application}repositories { mavenCentral() }dependencies {implementation("io.github.libtmux:libtmux-kotlin:0.0.1-alpha.17-SNAPSHOT")}java { toolchain { languageVersion.set(JavaLanguageVersion.of(25)) } }kotlin { jvmToolchain(25) }application { mainClass.set(providers.gradleProperty("exampleMain")) }Save this consumer setup as gradle.properties: View source
org.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}")mkdir -p /tmp/libtmux-java-devdirectory=$(mktemp -d /tmp/libtmux-java-dev/api.XXXXXX)socket="$directory/tmux.sock"config="$directory/tmux.conf"alive() {"$binary" -S "$socket" display-message -p '#{pid}' >/dev/null 2>&1}cleanup() {status=$?trap - 0 HUP INT TERMif alive; thenif ! "$binary" -S "$socket" kill-server; thenprintf 'Cannot stop tmux; kept %s\n' "$directory" >&2exit 1fiattempts=0while alive && [ "$attempts" -lt 100 ]; dosleep 0.05attempts=$((attempts + 1))doneif alive; thenprintf 'tmux is still responding; kept %s\n' "$directory" >&2exit 1fifirm -rf "$directory" || exit 1exit "$status"}trap cleanup 0trap 'exit 1' HUP INT TERMunset TMUX TMUX_PANEprintf '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/kotlin/ListPanes.kt. It opens an ordinary client for the launcher's server; closing the client releases its transport. View source
package io.github.libtmux.examples.api.kotlinimport io.github.libtmux.ServerConfigimport io.github.libtmux.ServerEndpointimport io.github.libtmux.kotlin.*import io.github.libtmux.kotlin.query.nameimport java.nio.file.Pathimport kotlin.system.exitProcessimport kotlinx.coroutines.runBlocking/** List all panes, then the panes captured for one window. */fun main(args: Array<String>) {try {require(args.size == 3) { "expected: tmux-binary socket-path config-file" }val config = ServerConfig.builder().binary(args[0]).endpoint(ServerEndpoint.socketPath(Path.of(args[1]))).configFile(Path.of(args[2])).build()runBlocking {withServer(config) { server ->println("panes=${server.panes().size}")val session = server.session(Session.name eq "work-one")val window = session.windows.single { it.name == "editor" }println("window-panes=${window.panes.size}")}}} catch (error: Exception) {if (error is InterruptedException) Thread.currentThread().interrupt()System.err.println("Example failed: ${error.message}")exitProcess(1)}}Build the minimal consumer and run the saved program with the private fixture. An operation or cleanup error makes the command exit unsuccessfully:
Terminal window $ ./libtmux-source/gradlew --project-dir . --console=plain --quiet \installDist -PexampleMain=io.github.libtmux.examples.api.kotlin.ListPanesKt && \sh run.sh build/install/api-example/bin/api-exampleExpected output:
panes=4window-panes=2tmux command
list-panesIn other ports List a window's panes
- Python
libtmux.Window.panes - Ruby
LibTmux::Window#list_panes - Lua No source-verified Lua equivalent is recorded for this operation.
- TypeScript
window.Window.panes - Rust
window.Window.panes - Go
tmux.Window.Panes - Java
io.github.libtmux.Window.panes - C#
LibTmux.Window.Panes - C++
libtmux::Window::panes - Swift
Snapshot.panes(of:) - Scala
io.github.libtmux.scaladsl.Window.panes - F# No source-verified F# equivalent is recorded for this operation.
- Python