Core Library0.xAPI reference

Choose documentation 1

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.

MoreLess about this notice

method libtmux-scala

Pane.capture

This pane's visible content, one element per line.

Source and package
Qualified name
io.github.libtmux.scaladsl.cats.Pane.capture
Package
io.github.libtmux.scaladsl.cats
Declared in
Pane
Distribution
io.github.libtmux:libtmux-scala_3
Source
libtmux-scala-cats/build/generated/sources/catalog/scala/operations/GeneratedOperations.scala
Scala extension methodsAdds methods callable on the receiver type without changing its definition.Language documentation [F[_]](self: Pane[F])(using F: _root_.cats.effect.Async[F] ) Scala method declarationsDeclares a method, with its name, parameter lists and return type.Language documentation capture(): F[Vector[String]]Scala extension methodsAdds methods callable on the receiver type without changing its definition.Language documentation [F[_]](self: Pane[F])(using F: _root_.cats.effect.Async[F] ) Scala method declarationsDeclares a method, with its name, parameter lists and return type.Language documentation capture( configure: io.github.libtmux.CaptureSpec.Builder => Unit ): F[Vector[String]]Scala extension methodsAdds methods callable on the receiver type without changing its definition.Language documentation [F[_]](self: Pane[F])(using F: _root_.cats.effect.Async[F] ) Scala method declarationsDeclares a method, with its name, parameter lists and return type.Language documentation capture(spec: io.github.libtmux.CaptureSpec): F[ Vector[String] ]
Type parameters
Parameters

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/cat and /bin/sh available. In an empty directory, save this consumer setup as settings.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 {
scala
application
}
repositories { mavenCentral() }
dependencies {
implementation("io.github.libtmux:libtmux-scala-cats_3:0.1.2")
implementation("org.scala-lang:scala3-library_3:3.9.0")
}
java { toolchain { languageVersion.set(JavaLanguageVersion.of(25)) } }
application { mainClass.set(providers.gradleProperty("exampleMain")) }

Save this consumer setup as gradle.properties: View source

gradle.properties
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=768m -Dfile.encoding=UTF-8
kotlin.daemon.jvmargs=-Xmx2g
org.gradle.workers.max=2

Save this complete program as src/main/scala/Capture.scala. It starts a private tmux server of its own and stops it when the program closes it. View source

src/main/scala/Capture.scalaComplete program
package io.github.libtmux.examples.api.scalacats
import io.github.libtmux.{SessionSpec, TextOutcome}
import io.github.libtmux.scaladsl.cats.*
import scala.concurrent.duration.*
import _root_.cats.effect.{ExitCode, IO, IOApp}
import _root_.cats.syntax.all.*
/** Send input and wait for output before capturing the pane. */
object Capture extends IOApp {
def run(args: List[String]): IO[ExitCode] = {
val program = Server.start[IO]().use { server =>
for {
session <- server.newSession(
SessionSpec
.builder()
.named("api-capture")
.running("/bin/sh")
.build()
)
pane = session.windows.head.panes.head
_ <- pane.sendKeys(Vector("printf 'api-%s\\n' keys", "Enter"))
keys <- pane.awaitText("api-keys", 5.seconds)
_ <- IO.raiseWhen(keys.equals(TextOutcome.TIMED_OUT))(
new IllegalStateException("timed out waiting for keys output")
)
_ <- pane.sendLine("printf 'api-%s\\n' line")
line <- pane.awaitText("api-line", 5.seconds)
_ <- IO.raiseWhen(line.equals(TextOutcome.TIMED_OUT))(
new IllegalStateException("timed out waiting for line output")
)
lines <- pane.capture()
_ <- Vector("api-keys", "api-line").traverse_ { expected =>
IO.raiseUnless(lines.exists(_.trim.endsWith(expected)))(
new IllegalStateException("capture is missing " + expected)
) *> IO.println(expected)
}
} yield ()
}
program.as(ExitCode.Success).handleErrorWith { error =>
IO(System.err.println("Example failed: " + error.getMessage))
.as(ExitCode.Error)
}
}
}

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.scalacats.Capture && \
build/install/api-example/bin/api-example

Expected output:

api-keys
api-line

Recorded calls

source calls
No call edges in the Scala model.

The Scala 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.scaladsl.cats.Pane.capture.

tmux command

task material

The tmux commands behind capture.

tmux C API

task material

The C declarations in tmux that implement these commands.

In other ports

task equivalence 17 other ports mapped

Source-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.

Read a pane’s visible contents in each port
PortAPIDiffers from Scala
Scala io.github.libtmux.scaladsl.cats.Pane.capture
This pane's visible content, one element per line.
This page
Python libtmux.Pane.capture_pane
Capture text from pane.
None recorded in the model
Ruby LibTmux::Pane#capture
Behavior: Pane input and capture.
None recorded in the model
Lua libtmux.Pane:capture None recorded in the model
Erlang tmux_pane:capture/2
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.Pane.capture
Capture this pane's contents as lines.
None recorded in the model
Rust pane.Pane.capture
Capture the pane's visible contents, one entry per line.
async
Go tmux.Pane.Capture
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.github.libtmux.Pane.capture
This pane's visible content, one element per line.
None recorded in the model
Clojure libtmux.core/capture!
Captures pane lines; :from :history includes scrollback.
free function
Kotlin io.github.libtmux.kotlin.Pane.capture
This pane's visible content, one element per line.
async
C# LibTmux.Pane.CaptureAsync
Reads the pane's contents.
async
F# LibTmux.FSharp.Pane.capture
Captures pane contents using the supplied core request.
free function
C++ libtmux::Pane::capture
The visible contents, as tmux printed them.
readonly
Swift Server.capture(_:includingHistory:)
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.
asyncon Server
OCaml Libtmux_unix.Client.capture_text
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 LibTmux::Server::capture_pane
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 LibTmux::Model::PaneRef.capture
Acquire screen/history bytes with explicit bounds and whitespace options.
on PaneRef
No Haskell equivalent.

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.

Esc
Search in

Type to search.

Reference previewOpen reference