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

Session.newWindow

Creates a window in this session and returns that exact window.

Source and package
Qualified name
io.github.libtmux.scaladsl.cats.Session.newWindow
Package
io.github.libtmux.scaladsl.cats
Declared in
Session
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: Session[F])(using F: _root_.cats.effect.Async[F] ) Scala method declarationsDeclares a method, with its name, parameter lists and return type.Language documentation newWindow(name: String): F[Window[F]]Scala extension methodsAdds methods callable on the receiver type without changing its definition.Language documentation [F[_]](self: Session[F])(using F: _root_.cats.effect.Async[F] ) Scala method declarationsDeclares a method, with its name, parameter lists and return type.Language documentation newWindow( configure: io.github.libtmux.WindowSpec.Builder => Unit ): F[Window[F]]Scala extension methodsAdds methods callable on the receiver type without changing its definition.Language documentation [F[_]](self: Session[F])(using F: _root_.cats.effect.Async[F] ) Scala method declarationsDeclares a method, with its name, parameter lists and return type.Language documentation newWindow(spec: io.github.libtmux.WindowSpec): F[ Window[F] ]
Type parameters
Parameters

Examples

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

src/main/scala/NewWindow.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.*
/** Create a window and read the updated session. */
object NewWindow 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()
)
found <- server.session("work-one")
session <- IO.fromOption(found)(
new IllegalStateException("missing work-one")
)
window <- session.newWindow(
WindowSpec.builder().named("api-window").running("/bin/cat").build()
)
_ <- IO.println(s"created=${window.name}")
updated <- server.session("work-one")
refreshed <- IO.fromOption(updated)(
new IllegalStateException("missing work-one")
)
_ <- IO.println(
"windows=" + refreshed.windows.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.NewWindow && \
build/install/api-example/bin/api-example

Expected output:

created=api-window
windows=api-window,editor,logs

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.Session.newWindow.

tmux command

task material

The tmux commands behind newWindow.

tmux C API

task material

The C declarations in tmux that implement these commands.

In other ports

task equivalence 16 other ports mapped

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

Create a window in each port
PortAPIDiffers from Scala
Scala io.github.libtmux.scaladsl.cats.Session.newWindow
Creates a window in this session and returns that exact window.
This page
Python libtmux.Session.new_window
Create new window, returns new Window.
None recorded in the model
Ruby LibTmux::Session#new_window
Behavior: Creation.
None recorded in the model
Lua libtmux.Session:new_window None recorded in the model
Erlang tmux_window:create/2
Create a physical window in the session's next free index and observe it. Defaults to detached. Launch, cwd and environment follow tmux_session:create/2. Performs I/O and retains completed-mutation details if observation fails.
free function
TypeScript session.Session.newWindow
Create a window in this session and resolve it as a handle.
None recorded in the model
Rust session.Session.new_window
Create a window in this session and return it.
async
Go tmux.Session.NewWindow
NewWindow creates a winlink in the receiver session. Attach selects it as that session's current window; it is not a guarantee about clients attached to other sessions. The returned Window is freshly materialized in the receiver's exact session context, including when its stable WindowID is linked elsewhere.
None recorded in the model
Java io.github.libtmux.Session.newWindow
Creates a window in this session and returns that exact window.
None recorded in the model
Clojure libtmux.core/new-window!
Creates a window and returns a fresh captured window occurrence.
free function
Kotlin io.github.libtmux.kotlin.Session.newWindow
Creates a window in this session and returns that exact window.
async
C# LibTmux.Session.CreateWindowAsync
Creates a window in this session.
async
C++ libtmux::Session::new_window
Created detached: a library call that stole the terminal would be a surprise, and attaching is a separate decision.
readonly
Swift Server.newWindow(in:named:startDirectory:at:environment:shell:)
Creates a window in a session and returns its exact appearance.
asyncon Server
OCaml Libtmux_unix.Client.create_window
Create detached, rejecting an occupied explicit index.
free function
Perl LibTmux::Server::new_window
new_window(session => Session|session_id, name => string?, command => arrayref?, shell_command => string?, cwd => bytes?, environment => hashref?).
on Server
Explicit Server operation. Captured entities remain local observations; use a new snapshot to observe changes.
Raku LibTmux::Model::SessionRef.new-window
Create a window and return its reported identity without refreshing observations.
on SessionRef
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