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-kotlin

Pane.sendKeys

Sends an ordered group of key names to this pane, as tmux resolves them.

Source and package
Qualified name
io.github.libtmux.kotlin.Pane.sendKeys
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.Language documentation fun Pane.sendKeys(keys: List<String>): Unitpublic Kotlin suspending functionsAllows a function to call suspending operations and pause without blocking a thread. It does not start a coroutine by itself.Language documentation fun Pane.sendKeys( keys: List<String>, beforeSend: Runnable ): Unit
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 {
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 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/kotlin/Capture.kt. It starts a private tmux server of its own and stops it when the program closes it. View source

src/main/kotlin/Capture.ktComplete program
package io.github.libtmux.examples.api.kotlin
import io.github.libtmux.SessionSpec
import io.github.libtmux.TextOutcome
import io.github.libtmux.kotlin.*
import kotlin.system.exitProcess
import kotlinx.coroutines.runBlocking
import 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-example

Expected output:

api-keys
api-line

Same owner

containment 1 of 53 shown

Other members of io.github.libtmux.kotlin.Pane whose names share sendKeys. They sit on the same type; that does not make them behave alike.

All 53 members of Pane

Recorded calls

source calls
No call edges in the Kotlin model.

The 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.sendKeys.

tmux command

task material

The tmux commands behind sendKeys.

send-keys display-message list-panes -t window scope, cmd_list_panes_window (the pane is synchronized)

tmux C API

task material

The C declarations in tmux that implement these commands.

In other ports

task equivalence 16 other ports mapped

Source-verified mappings for Send keystrokes to a pane. A mapping says these APIs perform the same task. It does not say they share defaults, errors or completion: check each page.

Send keystrokes to a pane in each port
PortAPIDiffers from Kotlin
Kotlin io.github.libtmux.kotlin.Pane.sendKeys
Sends an ordered group of key names to this pane, as tmux resolves them.
This page
Python libtmux.Pane.send_keys
$ tmux send-keys to the pane.
None recorded in the model
Ruby LibTmux::Pane#send_keys
Behavior: Pane input and capture.
None recorded in the model
Lua libtmux.Pane:send_keys None recorded in the model
Erlang tmux_pane:send_keys/2
Send at most 256 validated key tokens. Named keys, single UTF-8 characters, function keys and control-letter tuples are supported. Performs I/O; terminal modes determine the resulting input bytes. Use send_text/2 for arbitrary bytes.
free function
Common Lisp libtmux:send-keys
Send a finite nonempty list/vector of tmux key strings to PANE. Return a COMMAND-OUTCOME. REPEAT is a positive count. Tmux interprets key names such as C-c and Enter; its unrecognized strings fall back to literal input. Use SEND-TEXT when key-name interpretation must be disabled. Acknowledgment does not prove application readiness or consumption.
on client
TypeScript pane.Pane.sendKeys
Send keys to this pane, following them with Enter unless told not to.
None recorded in the model
Rust pane.Pane.send_keys
Send keys to the pane as if typed.
None recorded in the model
Go tmux.Pane.SendKeys
SendKeys invokes tmux send-keys with the receiver's exact linked session-window-pane target. This is tmux key input, not shell execution: Literal only changes tmux key parsing, and any delivered text may still be interpreted by the pane's application. KeyName routes through a client's key table instead of delivering to the pane.
None recorded in the model
Clojure libtmux.core/send-keys!
Sends an explicit vector of tmux key names.
free function
Scala io.github.libtmux.scaladsl.Pane.sendKeys
Sends an ordered group of key names to this pane, as tmux resolves them.
None recorded in the model
C# LibTmux.Pane.SendKeysAsync
Sends keys to the pane.
None recorded in the model
C++ libtmux::Pane::send_text
Literal text, never interpreted as key names or formats, and never followed by a newline the caller did not ask for.
readonly
Swift Server.sendKeys(_:to:literally:)
Sends keys to a pane.
on Server
OCaml Libtmux_unix.Client.send_keys
Send named tmux keys in order, without an implicit Enter. Use send_text for literal bytes rather than key interpretation.
free function
Perl LibTmux::Server::send_keys
send_keys(pane => Pane|pane_id, keys => arrayref).
on Server
Explicit Server operation. Captured entities remain local observations; use a new snapshot to observe changes.
Raku LibTmux::Model::PaneRef.send-keys
Send native key names, repeating them the requested number of times.
on PaneRef
No Haskell equivalent.

No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.

No Java equivalent.

no direct equivalent; Pane.paste writes a buffer instead

No equivalent is recorded in PowerShell, Julia, Elixir or F#.

Esc
Search in

Type to search.

Reference previewOpen reference