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

Creates a detached session and returns that exact session.

Source and package
Qualified name
io.github.libtmux.scaladsl.cats.Server.newSession
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 newSession(name: String): F[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 newSession( configure: io.github.libtmux.SessionSpec.Builder => Unit ): F[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 newSession(spec: io.github.libtmux.SessionSpec): F[ Session[F] ]
Type parameters
Parameters

Examples

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

src/main/scala/NewSession.scalaComplete program
package io.github.libtmux.examples.api.scalacats
import io.github.libtmux.{SessionSpec}
import io.github.libtmux.scaladsl.cats.*
import _root_.cats.effect.{ExitCode, IO, IOApp}
import _root_.cats.syntax.all.*
/** Create a session running cat. */
object NewSession extends IOApp {
def run(args: List[String]): IO[ExitCode] = {
val program = Server.start[IO]().use { server =>
for {
session <- server.newSession(
SessionSpec
.builder()
.named("api-session")
.running("/bin/cat")
.build()
)
_ <- IO.println(s"created=${session.name}")
} 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.NewSession && \
build/install/api-example/bin/api-example

Expected output:

created=api-session

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

tmux command

task material

The tmux commands behind newSession.

tmux C API

task material

The C declarations in tmux that implement these commands.

Each path starts at a function a command runs, which is degree 1. The degree counts steps from there along the path, and each step is a call or a reference: degree 2 is reached from that function, degree 3 from the next, and so on.

Create a session and its first pane

  1. 1 cmd_new_session_exec
  2. calls → 2 spawn_window
  3. calls → 3 spawn_pane
  4. calls → 4 window_add_pane
  5. calls → 5 window_pane_create

In other ports

task equivalence 16 other ports mapped

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

Create a session in each port
PortAPIDiffers from Scala
Scala io.github.libtmux.scaladsl.cats.Server.newSession
Creates a detached session and returns that exact session.
This page
Python libtmux.Server.new_session
Create new session, returns new Session.
None recorded in the model
Ruby LibTmux::Server#new_session
Behavior: Creation.
None recorded in the model
Lua libtmux.Server:new_session None recorded in the model
Erlang tmux_session:create/2
Create a detached session by default and explicitly observe the returned row. Options include name, window_name, dimensions, cwd, env and launch. Performs I/O; an observation failure after successful creation retains mutation = completed and the original command result. Existing names are not adopted.
free function
TypeScript server.Server.newSession
Create a detached session and resolve it as a handle.
None recorded in the model
Rust server.Server.new_session
Create a detached session and return it.
async
Go tmux.Server.NewSession
NewSession creates a detached session, then returns a newly materialized Session. It never changes client focus. KillExisting is not rolled back; transport and context failures may be delivery-ambiguous.
None recorded in the model
Java io.github.libtmux.Server.newSession
Creates a detached session and returns that exact session.
None recorded in the model
Clojure libtmux.core/new-session!
Creates a detached session and returns a fresh captured session map.
free function
Kotlin io.github.libtmux.kotlin.Server.newSession
Creates a detached session and returns that exact session.
async
C# LibTmux.Server.CreateSessionAsync
Creates a session.
async
C++ libtmux::Server::new_session
Created detached, and returned, because tmux prints what it made.
readonly
Swift Server.newSession(named:startDirectory:windowName:width:height:environment:shell:)
Creates a detached session.
async
OCaml Libtmux_unix.Client.create_session
Create a detached session on the bound daemon. Name collisions fail.
free function
Perl LibTmux::Server::new_session
new_session(name => string, command => arrayref?, shell_command => string?, width => integer?, height => integer?, cwd => bytes?, environment => hashref?).
Explicit Server operation. Captured entities remain local observations; use a new snapshot to observe changes.
Raku LibTmux::Server.new-session
Create a detached session and return its value-only, identity-scoped reference.
None recorded in the model
No Haskell equivalent.

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

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

Esc
Search in

Type to search.

Reference previewOpen reference