libtmux Reference MCP Search
On this page

tmux.Session.NewWindow

View as Markdown

Module
tmux
Declared in
Session
Package
github.com/libtmux/libtmux-go/tmux
Source
tmux/window_lifecycle.go
Other languages
PythonTypeScriptRustJava.NETC++Swift
NewWindow ( ctx : context.Context , request : NewWindowRequest ) (Window, error)
method [source]
method [source]
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.

SelectExisting no-output recovery is available only when Index is nil. It expands Name with tmux's version-specific rules and requires exactly one matching window name in the receiver session. An explicit Index has no such recovery. If tmux reports a WindowID before a transport or refresh failure, the partial result contains that ID and the receiver SessionID with Index -1. Other failures return zero; creation is not rolled back.

In other languages Create a window

Examples

>>> window_initial = session.new_window(window_name='Example')
>>> window_initial
Window(@... 2:Example, Session($1 libtmux_...))
>>> window_initial.window_index
'2'
>>> window_before = session.new_window(
... window_name='Window before', direction=WindowDirection.Before)
>>> window_initial.refresh()
>>> window_before
Window(@... 1:Window before, Session($1 libtmux_...))
>>> window_initial
Window(@... 3:Example, Session($1 libtmux_...))
>>> window_after = session.new_window(
... window_name='Window after', direction=WindowDirection.After)
>>> window_initial.refresh()
>>> window_after.refresh()
>>> window_after
Window(@... 3:Window after, Session($1 libtmux_...))
>>> window_initial
Window(@... 4:Example, Session($1 libtmux_...))
>>> window_before
Window(@... 1:Window before, Session($1 libtmux_...))
const created = await session.newWindow({ name: "editor" });
created.name; // "editor"

0 declared, 0 inherited

Esc

Type to search.