libtmux Reference MCP Search
On this page

session.Session.new_window

View as Markdown

Module
session
Declared in
Session
Package
libtmux
Source
crates/libtmux/src/session.rs
Other languages
PythonTypeScriptGoJava.NETC++Swift
new_window ( self , options : impl Into<NewWindowOptions> ) Result<Window, Error>
method [source]
method [source]
new_window

Create a window in this session and return it.

Errors

Returns an error when tmux refuses the command or its output cannot be decoded. tmux expands the name as a format before it checks it, so #(command) in one runs a shell command. See [the crate documentation][crate#a-name-reaches-tmux-as-a-format] before passing text a caller supplied.

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.