Pane.capture
This pane's visible content, one element per line.
Source and package
- Qualified name
-
io.github .libtmux .kotlin .Pane. capture - Package
- io.github.libtmux.kotlin
- Declared in
Pane- Distribution
- io.github.libtmux:libtmux-kotlin
- Source
- libtmux-kotlin/build/generated/sources/operations/kotlin/io/github/libtmux/kotlin/PaneOperations.kt
- public
Kotlin suspending functionsAllows a function to call suspending operations and pause without blocking a thread. It does not start a coroutine by itself. fun Pane.capture(): List<String>publicKotlin suspending functionsAllows a function to call suspending operations and pause without blocking a thread. It does not start a coroutine by itself. fun Pane.capture(spec: CaptureSpec ): List< String > -
- Parameters
-
-
spec(CaptureSpec ) forcapture(spec)
-
Examples
Send input and wait for output before capturing the pane. 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 {kotlin("jvm") version "2.4.10"application}repositories { mavenCentral() }dependencies {implementation("io.github.libtmux:libtmux-kotlin:0.1.2")}java { toolchain { languageVersion.set(JavaLanguageVersion.of(25)) } }kotlin { jvmToolchain(25) }application { mainClass.set(providers.gradleProperty("exampleMain")) }Save this consumer setup as
gradle.properties: View sourcegradle.properties org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=768m -Dfile.encoding=UTF-8kotlin.daemon.jvmargs=-Xmx2gorg.gradle.workers.max=2Save this complete program as
src/main/kotlin/Capture.kt. It starts a private tmux server of its own and stops it when the program closes it. View sourcesrc/main/kotlin/Capture.ktComplete program package io.github.libtmux.examples.api.kotlinimport io.github.libtmux.SessionSpecimport io.github.libtmux.TextOutcomeimport io.github.libtmux.kotlin.*import kotlin.system.exitProcessimport kotlinx.coroutines.runBlockingimport kotlin.time.Duration.Companion.seconds/** Send input and wait for output before capturing the pane. */fun main() {try {runBlocking {withPrivateServer { server ->val session = server.newSession(SessionSpec.builder().named("api-capture").running("/bin/sh").build())val pane = session.windows.first().panes.first()pane.sendKeys(listOf("printf 'api-%s\\n' keys", "Enter"))check(pane.awaitText("api-keys", timeout = 5.seconds) != TextOutcome.TIMED_OUT) {"timed out waiting for keys output"}pane.sendLine("printf 'api-%s\\n' line")check(pane.awaitText("api-line", timeout = 5.seconds) != TextOutcome.TIMED_OUT) {"timed out waiting for line output"}val lines = pane.capture()for (expected in listOf("api-keys", "api-line")) {check(lines.any { it.trim().endsWith(expected) }) { "capture is missing $expected" }println(expected)}}}} catch (error: Exception) {if (error is InterruptedException) Thread.currentThread().interrupt()System.err.println("Example failed: ${error.message}")exitProcess(1)}}Build the minimal consumer with Gradle and run the saved program. An operation or cleanup error makes the command exit unsuccessfully:
Terminal window $ gradle --console=plain --quiet installDist -PexampleMain=io.github.libtmux.examples.api.kotlin.CaptureKt && \build/install/api-example/bin/api-exampleExpected output:
api-keysapi-line
Recorded calls
source callsThe Kotlin reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls io.github.libtmux.kotlin.Pane.capture.
tmux command
task materialThe tmux commands behind capture.
tmux C API
task materialThe C declarations in tmux that implement these commands.
Guides
task materialPages that discuss capture.
In other ports
task equivalence 17 other ports mappedSource-verified mappings for Read a pane’s visible contents. A mapping says these APIs perform the same task. It does not say they share defaults, errors or completion: check each page.
| Port | API | Differs from Kotlin |
|---|---|---|
| Kotlin | io This pane's visible content, one element per line. | This page |
| Python | libtmux Capture text from pane. | 3 overloads |
| Ruby | Lib Behavior: Pane input and capture. | None recorded in the model |
| Lua | libtmux | None recorded in the model |
| Erlang | tmux Capture terminal bytes, preserving final newlines. Options select line range, joined wraps, escapes, alternate screen and padding; defaults follow tmux current-screen capture. Performs I/O and returns an explicit output-limit error instead of silently truncating. | free function |
| TypeScript | pane Capture this pane's contents as lines. | None recorded in the model |
| Rust | pane Capture the pane's visible contents, one entry per line. | None recorded in the model |
| Go | tmux Capture captures printed content from the receiver's exact linked pane. It returns a caller-owned slice. Completed stderr becomes a CommandError; any stdout tmux still printed is returned alongside it. A nonzero exit with empty stderr is not an error, as for every command (see the package documentation), and its stdout is returned. | None recorded in the model |
| Java | io This pane's visible content, one element per line. | 3 overloads |
| Clojure | libtmux Captures pane lines; :from :history includes scrollback. | free function |
| Scala | io This pane's visible content, one element per line. | 3 overloads |
| C# | Lib Reads the pane's contents. | None recorded in the model |
| F# | Lib Captures pane contents using the supplied core request. | free function |
| C++ | libtmux:: The visible contents, as tmux printed them. | readonly |
| Swift | Server The pane's visible contents, one line per row. The source read is capped at 1 MiB; use incremental capture for a large scrollback instead of collecting its entire history. | on Server |
| OCaml | Libtmux Capture ordinary rendered screen rows, inclusively, via an owned paste buffer and private file. Reject applicable capture/save hooks. The scratch directory defaults to /tmp and must be local storage shared with the daemon. Pending and alternate-screen byte modes are unsupported. This observes an interval and establishes no stream continuity barrier. | free function |
| Perl | Lib capture_pane(pane => Pane|pane_id, start => integer?, end => integer?). | on Server Explicit Server operation. Captured entities remain local observations; use a new snapshot to observe changes. |
| Raku | Lib Acquire screen/history bytes with explicit bounds and whitespace options. | on PaneRef |
No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
No equivalent is recorded in PowerShell, Julia, Elixir or Common Lisp.