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

Server.sessions

The sessions this expression matches, captured now.

Source and package
Qualified name
io.github.libtmux.scaladsl.cats.Server.sessions
Package
io.github.libtmux.scaladsl.cats
Declared in
Server
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: Server[F])(using F: _root_.cats.effect.Async[F] ) Scala method declarationsDeclares a method, with its name, parameter lists and return type.Language documentation sessions( expression: io.github.libtmux.scaladsl.query.Expr[ io.github.libtmux.Session ] ): F[Vector[Session[F]]]Scala extension methodsAdds methods callable on the receiver type without changing its definition.Language documentation [F[_]](self: Server[F])(using F: _root_.cats.effect.Async[F] ) Scala method declarationsDeclares a method, with its name, parameter lists and return type.Language documentation sessions(): F[Vector[Session[F]]]
Type parameters
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 {
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/ListSessions.scala. It starts a private tmux server of its own and stops it when the program closes it. View source

src/main/scala/ListSessions.scalaComplete program
package io.github.libtmux.examples.api.scalacats
import io.github.libtmux.{SessionSpec, SplitSpec, WindowSpec}
import io.github.libtmux.scaladsl.cats.*
import _root_.cats.effect.{ExitCode, IO, IOApp}
import _root_.cats.syntax.all.*
/** List the sessions returned by a server read. */
object ListSessions extends IOApp {
def run(args: List[String]): IO[ExitCode] = {
val program = Server.start[IO]().use { server =>
for {
workOne <- server.newSession(
SessionSpec
.builder()
.named("work-one")
.firstWindowNamed("editor")
.running("/bin/cat")
.build()
)
_ <- workOne.windows.head.split(
SplitSpec.builder().toRight().running("/bin/cat").build()
)
_ <- workOne.newWindow(
WindowSpec
.builder()
.named("logs")
.running("/bin/cat")
.detached()
.build()
)
_ <- server.newSession(
SessionSpec
.builder()
.named("work-two")
.firstWindowNamed("editor")
.running("/bin/cat")
.build()
)
sessions <- server.sessions()
_ <- IO.println(
"sessions=" + sessions.map(_.name).sorted.mkString(",")
)
} 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.ListSessions && \
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 {
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/Query.scala. It starts a private tmux server of its own and stops it when the program closes it. View source

src/main/scala/Query.scalaComplete program
package io.github.libtmux.examples.api.scalacats
import io.github.libtmux.{SessionSpec, SplitSpec, WindowSpec}
import io.github.libtmux.scaladsl.cats.*
import io.github.libtmux.scaladsl.{Session as SessionFields}
import io.github.libtmux.scaladsl.query.*
import _root_.cats.effect.{ExitCode, IO, IOApp}
import _root_.cats.syntax.all.*
/** Select sessions with a typed name filter. */
object Query extends IOApp {
def run(args: List[String]): IO[ExitCode] = {
val program = Server.start[IO]().use { server =>
for {
workOne <- server.newSession(
SessionSpec
.builder()
.named("work-one")
.firstWindowNamed("editor")
.running("/bin/cat")
.build()
)
_ <- workOne.windows.head.split(
SplitSpec.builder().toRight().running("/bin/cat").build()
)
_ <- workOne.newWindow(
WindowSpec
.builder()
.named("logs")
.running("/bin/cat")
.detached()
.build()
)
_ <- server.newSession(
SessionSpec
.builder()
.named("work-two")
.firstWindowNamed("editor")
.running("/bin/cat")
.build()
)
matches <- server.sessions(SessionFields.name.is("work-one"))
_ <- IO.println("matches=" + matches.map(_.name).sorted.mkString(","))
} 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.Query && \
build/install/api-example/bin/api-example

Expected output:

matches=work-one

Same owner

containment 1 of 48 shown

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

All 48 members of Server

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.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 Scala
Scala io.github.libtmux.scaladsl.cats.Server.sessions
The sessions this expression matches, 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.
async
Rust server.Server.sessions
List every session on the server, preserving any failure.
async
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.
Kotlin io.github.libtmux.kotlin.Server.sessions
Every session, captured now.
async
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.
async
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