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

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.Language documentation fun Server.sessions(): List<Session>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 Server.sessions( expression: FilterExpr<io.github.libtmux.Session> ): List<Session>
Parameters

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/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/ListSessions.kt. It starts a private tmux server of its own and stops it when the program closes it. View source

src/main/kotlin/ListSessions.ktComplete program
package io.github.libtmux.examples.api.kotlin
import io.github.libtmux.SplitSpec
import io.github.libtmux.kotlin.*
import kotlin.system.exitProcess
import 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-example

Expected output:

sessions=work-one,work-two

Select sessions with a typed name filter. 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/Query.kt. It starts a private tmux server of its own and stops it when the program closes it. View source

src/main/kotlin/Query.ktComplete program
package io.github.libtmux.examples.api.kotlin
import io.github.libtmux.SplitSpec
import io.github.libtmux.kotlin.*
import io.github.libtmux.kotlin.query.name
import kotlin.system.exitProcess
import 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-example

Expected output:

matches=work-one

Same owner

containment 1 of 51 shown

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

All 51 members of Server

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.Server.sessions.

tmux command

task material

The tmux commands behind sessions.

tmux C API

task material

The C declarations in tmux that implement these commands.

In other ports

task equivalence 21 other ports mapped

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

List the server’s sessions in each port
PortAPIDiffers from Kotlin
Kotlin io.github.libtmux.kotlin.Server.sessions
Every session, captured now.
This page
Python libtmux.Server.sessions
Sessions contained in server.
None recorded in the model
Ruby LibTmux::Server#list_sessions
Behavior: Live acquisition.
None recorded in the model
Lua libtmux.Snapshot.sessions None recorded in the model
PowerShell LibTmux\Get-TmuxSession
Read sessions with optional exact selectors.
free function
Acquires sessions through -Server, with optional exact -Id and -Name selectors.
Julia LibTmux.sessions free function
sessions reads membership from a captured Snapshot without contacting tmux.
Erlang tmux_snapshot:sessions/1
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 LibTmux.Snapshot.sessions/1
Returns a materialized session selection without I/O.
on Snapshot
Returns a Selection of captured sessions without contacting tmux.
Common Lisp libtmux:sessions
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.Server.sessions
Every session on the server, read now.
None recorded in the model
Rust server.Server.sessions
List every session on the server, preserving any failure.
None recorded in the model
Go tmux.Server.Sessions
Sessions materializes the server's sessions. Failures, including ErrNoServer, remain errors rather than empty results.
None recorded in the model
Java io.github.libtmux.Server.sessions
The sessions this expression matches, captured now.
None recorded in the model
Clojure libtmux.core/sessions!
Acquires captured sessions; acquisition failure throws.
free function
Acquires a new captured graph and returns its session maps; acquisition failure throws.
Scala io.github.libtmux.scaladsl.Server.sessions
The sessions this expression matches, captured now.
None recorded in the model
C# LibTmux.Server.Sessions
Gets the sessions this handle captured.
None recorded in the model
F# LibTmux.FSharp.Server.sessions
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::Server::sessions
One snapshot each.
readonly
Swift Server.sessions()
Every session on this server, in tmux's own order.
None recorded in the model
OCaml Libtmux.Snapshot.sessions free function
Reads an immutable array of already captured sessions without I/O.
Perl LibTmux::Snapshot::sessions
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 LibTmux::Model::Snapshot.sessions
Captured sessions in acquisition order; reading performs no I/O.
on Snapshot
No Haskell equivalent.

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

Esc
Search in

Type to search.

Reference previewOpen reference