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

class libtmux-scala

Server

A tmux server whose operations run in the effect type F.

Source and package
Qualified name
io.github.libtmux.scaladsl.cats.Server
Package
io.github.libtmux.scaladsl.cats
Distribution
io.github.libtmux:libtmux-scala_3
Source
libtmux-scala-cats/src/main/scala/io/github/libtmux/scaladsl/cats/Server.scala
final class Server[F[_]]object Server

Description

Acquire it with Server.resource, or borrow a Java client with Server.fromJava. Releasing the Resource cancels this scope's operations and closes an owned client. Cancellation does not roll back commands already sent to tmux, and closing the client does not stop the tmux server.

Type parameters
  • F for Server() [overload 1]

Examples

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

src/main/scala/Connect.scalaComplete program
package io.github.libtmux.examples.api.scalacats
import io.github.libtmux.scaladsl.cats.*
import _root_.cats.effect.{ExitCode, IO, IOApp}
import _root_.cats.syntax.all.*
/** Connect to a private tmux server. */
object Connect extends IOApp {
def run(args: List[String]): IO[ExitCode] = {
val program = Server.start[IO]().use { server =>
for {
alive <- server.isAlive()
_ <- IO.println(s"connected=$alive")
} 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.Connect && \
build/install/api-example/bin/api-example

Expected output:

connected=true

Members48 members

Collections and queries6

  • sessions method The sessions this expression matches, captured now.
  • windows method Captures every winlink, preserving each session and index placement.
  • panes method Captures every pane on the server.
  • clients method Captures every attached client.
  • buffers method The server's paste buffers, which every session shares.
  • snapshot method Captures the whole hierarchy in at most four listings, retrying once if the server is replaced.

Common operations5

  • newSession method Creates a detached session and returns that exact session.
  • killServer method Ends the tmux server and every session on it.
  • fromJava method Borrows Java without closing it. The bound covers this facade only; transport capacity and interruption remain the owner's responsibility.
  • resource method Owns a Java client, with one to four simultaneous facade calls. Release cancels queued and running operations before closing the client.
  • start method Starts a private tmux server and owns it: release ends tmux, removes its directory and fails if the server still answers. As resource for the facade's operation bound and cancellation.

Other members37

  • admissionBound method How many tmux commands this server's transport runs at once, from ServerConfig#maxConcurrentCommands() for a server #opened here.
  • asJava property The Java client this wraps: the one escape hatch, as on every handle.
  • attachedSessions method Captures every session a client is attached to.
  • batch method An immutable batch plan; each run dispatches a fresh Java Batch through this server's Execution.
  • batchReservingCapacity method Collects a group that may wait for a release through this server's transport.
  • captureServer method Captures metadata and entity handles from one observed hierarchy.
  • chain method An immutable chain plan using tmux's evolving current target; each run dispatches a fresh Java CommandChain through this server's Execution.
  • chainReservingCapacity method Starts an implicit-target chain while reserving transport capacity for its release.
  • channel method One of tmux's wait-for channels, named once.
  • cmd method Runs one tmux command against this server.
  • commands method The commands this tmux knows.
  • config method How this server was configured.
  • environment method The server's environment, which every session inherits and every new process is given.
  • expand method Expands a tmux format against the server, and answers with what it came to.
  • globalOptions method The global session options every session inherits unless it sets its own.
  • hasSession method Whether a session with this name exists.
  • hooks method The global hooks every session inherits.
  • identity method Which server this is.
  • isAlive method Whether the server is running and answering.
  • keys method The server's key bindings: prefix when binding, every table when listing.
  • killSession method Ends the session with this name, and everything in it.
  • lock method Locks every client attached to this server.
  • messageLog method The server's message log.
  • options method The server-wide options, the ones tmux keeps once per server.
  • pane method The one pane this expression matches, captured now, or empty when none does.
  • paneFields method Chosen fields for every pane on the server, from one listing.
  • prompt method The command prompt's history.
  • requireAlive method Requires a running tmux daemon that answers the liveness probe.
  • requireCompatibleTmux method Requires a compatible daemon, or a compatible executable when this endpoint is unused.
  • run method Runs a command that is expected to work, and raises when it did not.
  • session method The one session this expression matches, captured now, or empty when none does.
  • shell method Shell commands run by tmux, and tmux commands chosen by a shell exit status.
  • sourceFile method Runs a file of tmux commands, as a configuration file would be run.
  • toBuilder method A builder holding every configuration and ownership choice this server made.
  • variables method Reads only validated tmux variable names, never caller-authored format syntax.
  • version method Which tmux this server is running.
  • window method The one window link this expression matches, captured now, or empty when none does.

Order: the accessors that walk the hierarchy, the operations the ports share, then the rest.

In other ports

task equivalence 22 other ports mapped

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

A tmux server in each port
PortAPIDiffers from Scala
Scala io.github.libtmux.scaladsl.cats.Server
A tmux server whose operations run in the effect type F.
This page
Python libtmux.Server
tmux(1) Server [server_manual].
None recorded in the model
Ruby LibTmux::Server
Connects to an existing endpoint. Closing retires clients, never the daemon.
None recorded in the model
Lua libtmux.Server None recorded in the model
PowerShell LibTmux\New-TmuxServer
Construct a tmux endpoint handle without contacting it.
This cmdlet constructs a shared .NET LibTmux.Server handle without contacting tmux.
Julia LibTmux.Server
Describe a tmux endpoint without contacting it. Supply exactly one socket selector. A description does not own a daemon or any sessions. Use from_env to opt into the ambient tmux endpoint.
Server describes an endpoint without contacting tmux. Read its hierarchy with snapshot.
Erlang tmux_server
Open tmux endpoints and execute explicit command values.
open/1 observes an existing daemon and starts an endpoint owner. Domain rows remain immutable values.
Elixir LibTmux.Server
An explicit local tmux server descriptor.
Server describes an existing server by executable and socket. It neither connects nor reserves the server’s identity.
Haskell LibTmux.Server
Start, observe and change a tmux daemon through a scoped handle.
LibTmux.Server owns the Server handle. withOwnedServer starts and retires a private daemon; withServer borrows an existing endpoint and releases its own resources afterwards. killServer retires the admitted daemon generation explicitly. Operations such as capture and renameSession are functions of this module that take the handle.
Common Lisp libtmux:client
A connection scope with one external-operation lease. Closing cancels owned work and leaves the tmux daemon alive. Captured data may outlive the client. Public operations never expose its mutable storage.
client is a connection scope with one external-operation lease. Closing it cancels owned work and leaves the tmux daemon alive; daemon owns a daemon the library started.
TypeScript server.Server
One tmux server, addressed by the socket it listens on.
None recorded in the model
Rust server.Server
A cloneable handle to one captured tmux server endpoint.
None recorded in the model
Go tmux.Server
Server is an immutable handle to one tmux configuration. Its zero value is invalid. Copying a configured Server preserves its configuration and shares its mutex-guarded version cache and checked daemon identity, so a Server and the values derived from it are safe for concurrent method calls (see the package documentation).
None recorded in the model
Java io.github.libtmux.Server
Manages sessions, windows, and panes on a tmux server.
readonly
Clojure libtmux.core/open!
Opens local resources for an explicit :socket-path or :socket-name endpoint.
Opens a closeable Java server client for an explicit endpoint. Acquisitions return persistent maps with explicit Java references for effects.
Kotlin io.github.libtmux.kotlin.Server
Manages sessions, windows, and panes on a tmux server.
None recorded in the model
C# LibTmux.Server
Represents an immutable server handle and snapshot.
None recorded in the model
F# LibTmux.FSharp.Server
Starts server reads and queries with the caller's cancellation token.
This F# module provides functions over the shared .NET LibTmux.Server type.
C++ libtmux::Server
One tmux server, addressed by the socket it listens on.
None recorded in the model
Swift Server
A tmux server, addressed by its endpoint.
None recorded in the model
OCaml Libtmux_unix.Client
An explicit generation-bound connection. Applications retain ownership of the endpoint choice and resource lifetime.
A client is a live, generation-bound server connection. Endpoint describes a socket without connecting; closing a client releases its resources.
Perl LibTmux::Server
Explicit tmux acquisition and commands
Construction records connection settings without tmux I/O. Optional LibTmux::Async::Server returns standard Future results for operations.
Raku LibTmux::Server None recorded in the model
Esc
Search in

Type to search.

Reference previewOpen reference