Session.newWindow
Creates a window in this session and returns that exact window.
Source and package
- Qualified name
-
io.github .libtmux .kotlin .Session. new Window - Package
- io.github.libtmux.kotlin
- Declared in
Session- Distribution
- io.github.libtmux:libtmux-kotlin
- Source
- libtmux-kotlin/build/generated/sources/operations/kotlin/io/github/libtmux/kotlin/SessionOperations.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. fun Session.newWindow(name: String): WindowpublicKotlin suspending functionsAllows a function to call suspending operations and pause without blocking a thread. It does not start a coroutine by itself. fun Session.newWindow( spec: WindowSpec ): Window -
- Parameters
-
-
spec(WindowSpec ) fornewWindow(spec)
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/catand/bin/shavailable. In an empty directory, save this consumer setup assettings.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 sourcegradle.properties org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=768m -Dfile.encoding=UTF-8kotlin.daemon.jvmargs=-Xmx2gorg.gradle.workers.max=2Save this complete program as
src/main/kotlin/NewWindow.kt. It starts a private tmux server of its own and stops it when the program closes it. View sourcesrc/main/kotlin/NewWindow.ktComplete program package io.github.libtmux.examples.api.kotlinimport io.github.libtmux.WindowSpecimport io.github.libtmux.SplitSpecimport io.github.libtmux.kotlin.*import io.github.libtmux.kotlin.query.nameimport kotlin.system.exitProcessimport kotlinx.coroutines.runBlocking/** Create a window and read the updated session. */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 session = server.session(Session.name eq "work-one")val window = session.newWindow(WindowSpec.builder().named("api-window").running("/bin/cat").build())println("created=${window.name}")val refreshed = server.session(Session.name eq "work-one")println("windows=" + refreshed.windows.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.NewWindowKt && \build/install/api-example/bin/api-exampleExpected output:
created=api-windowwindows=api-window,editor,logs
Recorded calls
source callsThe 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.Session.newWindow.
tmux command
task materialThe tmux commands behind newWindow.
tmux C API
task materialThe C declarations in tmux that implement these commands.
In other ports
task equivalence 16 other ports mappedSource-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.
| Port | API | Differs from Kotlin |
|---|---|---|
| Kotlin | io Creates a window in this session and returns that exact window. | This page |
| Python | libtmux Create new window, returns new Window. | None recorded in the model |
| Ruby | Lib Behavior: Creation. | None recorded in the model |
| Lua | libtmux | None recorded in the model |
| Erlang | tmux 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 Create a window in this session and resolve it as a handle. | None recorded in the model |
| Rust | session Create a window in this session and return it. | None recorded in the model |
| Go | tmux 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 Creates a window in this session and returns that exact window. | 3 overloads |
| Clojure | libtmux Creates a window and returns a fresh captured window occurrence. | free function |
| Scala | io Creates a window in this session and returns that exact window. | 3 overloads |
| C# | Lib Creates a window in this session. | None recorded in the model |
| C++ | libtmux:: Created detached: a library call that stole the terminal would be a surprise, and attaching is a separate decision. | readonly |
| Swift | Server Creates a window in a session and returns its exact appearance. | on Server |
| OCaml | Libtmux Create detached, rejecting an occupied explicit index. | free function |
| Perl | Lib 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 | Lib Create a window and return its reported identity without refreshing observations. | on SessionRef |
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#.