Pane.sendLine
Sends a line to this pane and presses Enter, which is how a command gets run.
Source and package
- Qualified name
-
io.github .libtmux .scaladsl .Pane. send Line - Package
- io.github.libtmux.scaladsl
- Declared in
Pane- Distribution
- io.github.libtmux:libtmux-scala_3
- Source
- libtmux-scala/build/generated/sources/catalog/scala/operations/GeneratedOperations.scala
-
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 {scalaapplication}repositories { mavenCentral() }dependencies {implementation("io.github.libtmux:libtmux-scala_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 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/scala/Capture.scala. It starts a private tmux server of its own and stops it when the program closes it. View sourcesrc/main/scala/Capture.scalaComplete program package io.github.libtmux.examples.api.scaladirectimport io.github.libtmux.{SessionSpec, TextOutcome}import io.github.libtmux.scaladsl.*import scala.concurrent.duration.*import scala.util.Usingimport scala.util.control.NonFatal/** Send input and wait for output before capturing the pane. */object Capture {def main(args: Array[String]): Unit = {try {Using.resource(Server.start()) { server =>val session = server.newSession(SessionSpec.builder().named("api-capture").running("/bin/sh").build())val pane = session.windows.head.panes.headpane.sendKeys(Vector("printf 'api-%s\\n' keys", "Enter"))require(!pane.awaitText("api-keys", 5.seconds).equals(TextOutcome.TIMED_OUT),"timed out waiting for keys output")pane.sendLine("printf 'api-%s\\n' line")require(!pane.awaitText("api-line", 5.seconds).equals(TextOutcome.TIMED_OUT),"timed out waiting for line output")val lines = pane.capture()Vector("api-keys", "api-line").foreach { expected =>require(lines.exists(_.trim.endsWith(expected)),"capture is missing " + expected)println(expected)}}} catch {case NonFatal(error) =>System.err.println("Example failed: " + error.getMessage)sys.exit(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.scaladirect.Capture && \build/install/api-example/bin/api-exampleExpected output:
api-keysapi-line
Same owner
containment 1 of 62 shownOther members of io.github.libtmux.scaladsl.Pane whose names share sendLine. They sit on the same type; that does not make them behave alike.
Recorded calls
source callsThe 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.Pane.sendLine.
tmux command
task materialThe tmux commands behind sendLine.
tmux C API
task materialThe C declarations in tmux that implement these commands.