Server.sessions
Every session, captured now.
Source and package
- Qualified name
-
io.github .libtmux .kotlin .Server. sessions - Package
- io.github.libtmux.kotlin
- Declared in
Server- Distribution
- io.github.libtmux:libtmux-kotlin
- Source
- libtmux-kotlin/build/generated/sources/operations/kotlin/io/github/libtmux/kotlin/ServerOperations.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 Server.sessions(): List<Session>publicKotlin suspending functionsAllows a function to call suspending operations and pause without blocking a thread. It does not start a coroutine by itself. fun Server.sessions( expression: FilterExpr <io.github > ): List<Session>.libtmux .Session -
- Parameters
-
-
expression(FilterExpr <io.github >) for.libtmux .Session sessions(expression)
-
Examples
List the sessions returned by a server read. 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/ListSessions.kt. It starts a private tmux server of its own and stops it when the program closes it. View sourcesrc/main/kotlin/ListSessions.ktComplete program package io.github.libtmux.examples.api.kotlinimport io.github.libtmux.SplitSpecimport io.github.libtmux.kotlin.*import kotlin.system.exitProcessimport kotlinx.coroutines.runBlocking/** List the sessions returned by a server read. */fun main() {try {runBlocking {withPrivateServer { server ->val workOne = server.newSession {name = "work-one"window { name = "editor"; running("/bin/cat") }window { name = "logs"; running("/bin/cat") }}workOne.windows.first().split(SplitSpec.builder().toRight().running("/bin/cat").build())server.newSession {name = "work-two"window { name = "editor"; running("/bin/cat") }}println("sessions=" + server.sessions().map { it.name }.sorted().joinToString(","))}}} 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.ListSessionsKt && \build/install/api-example/bin/api-exampleExpected output:
sessions=work-one,work-twoSelect sessions with a typed name filter. 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/Query.kt. It starts a private tmux server of its own and stops it when the program closes it. View sourcesrc/main/kotlin/Query.ktComplete program package io.github.libtmux.examples.api.kotlinimport io.github.libtmux.SplitSpecimport io.github.libtmux.kotlin.*import io.github.libtmux.kotlin.query.nameimport kotlin.system.exitProcessimport kotlinx.coroutines.runBlocking/** Select sessions with a typed name filter. */fun main() {try {runBlocking {withPrivateServer { server ->val workOne = server.newSession {name = "work-one"window { name = "editor"; running("/bin/cat") }window { name = "logs"; running("/bin/cat") }}workOne.windows.first().split(SplitSpec.builder().toRight().running("/bin/cat").build())server.newSession {name = "work-two"window { name = "editor"; running("/bin/cat") }}val matches = server.sessions(Session.name eq "work-one")println("matches=" + matches.map { it.name }.sorted().joinToString(","))}}} 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.QueryKt && \build/install/api-example/bin/api-exampleExpected output:
matches=work-one
Same owner
containment 1 of 51 shownOther members of io.github.libtmux.kotlin.Server whose names share sessions. They sit on the same type; that does not make them behave alike.
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.Server.sessions.
tmux command
task materialThe tmux commands behind sessions.
tmux C API
task materialThe C declarations in tmux that implement these commands.
In other ports
task equivalence 21 other ports mappedSource-verified mappings for List the server’s sessions. 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 Every session, captured now. | This page |
| Python | libtmux Sessions contained in server. | None recorded in the model |
| Ruby | Lib Behavior: Live acquisition. | None recorded in the model |
| Lua | libtmux | None recorded in the model |
| PowerShell | Lib Read sessions with optional exact selectors. | free function |
| Julia | Lib | free function |
| Erlang | tmux Return captured sessions in numeric ID order. Performs no I/O and raises incomplete_snapshot when that collection was not captured. | free function Returns captured rows without tmux I/O. |
| Elixir | Lib Returns a materialized session selection without I/O. | on Snapshot Returns a Selection of captured sessions without contacting tmux. |
| Common Lisp | libtmux: Return a fresh vector of physical sessions in captured wire order. No I/O. | free function sessions returns a fresh vector from a captured snapshot without contacting tmux. |
| TypeScript | server Every session on the server, read now. | None recorded in the model |
| Rust | server List every session on the server, preserving any failure. | None recorded in the model |
| Go | tmux Sessions materializes the server's sessions. Failures, including ErrNoServer, remain errors rather than empty results. | None recorded in the model |
| Java | io The sessions this expression matches, captured now. | None recorded in the model |
| Clojure | libtmux Acquires captured sessions; acquisition failure throws. | free function Acquires a new captured graph and returns its session maps; acquisition failure throws. |
| Scala | io The sessions this expression matches, captured now. | None recorded in the model |
| C# | Lib Gets the sessions this handle captured. | None recorded in the model |
| F# | Lib Queries every session. | free function Builds a deferred session query on LibTmux.Server. Query.list acquires the results; it does not traverse the handle’s captured membership. |
| C++ | libtmux:: One snapshot each. | readonly |
| Swift | Server Every session on this server, in tmux's own order. | None recorded in the model |
| OCaml | Libtmux | free function Reads an immutable array of already captured sessions without I/O. |
| Perl | Lib Return a fresh LibTmux::SessionSelection in captured order. Empty loaded collections yield empty selections; unloaded collections throw. | on Snapshot Reads captured membership locally, preserving order. |
| Raku | Lib Captured sessions in acquisition order; reading performs no I/O. | on Snapshot |
No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.