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-kotlin

Session.newWindow

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

Source and package
Qualified name
io.github.libtmux.kotlin.Session.newWindow
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.Language documentation fun Session.newWindow(name: String): Windowpublic Kotlin suspending functionsAllows a function to call suspending operations and pause without blocking a thread. It does not start a coroutine by itself.Language documentation fun Session.newWindow( spec: WindowSpec ): Window
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 {
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 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/kotlin/NewWindow.kt. It starts a private tmux server of its own and stops it when the program closes it. View source

src/main/kotlin/NewWindow.ktComplete program
package io.github.libtmux.examples.api.kotlin
import io.github.libtmux.WindowSpec
import io.github.libtmux.SplitSpec
import io.github.libtmux.kotlin.*
import io.github.libtmux.kotlin.query.name
import kotlin.system.exitProcess
import 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-example

Expected output:

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

Recorded calls

source calls
No call edges in the Kotlin model.

The 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 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 Kotlin
Kotlin io.github.libtmux.kotlin.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.
None recorded in the model
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.
3 overloads
Clojure libtmux.core/new-window!
Creates a window and returns a fresh captured window occurrence.
free function
Scala io.github.libtmux.scaladsl.Session.newWindow
Creates a window in this session and returns that exact window.
3 overloads
C# LibTmux.Session.CreateWindowAsync
Creates a window in this session.
None recorded in the model
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.
on 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