- Module
- libtmux
- Declared in
- Session
- Package
- libtmux
- Source
- src/libtmux/session.py
- Other languages
- RubyLuaTypeScriptRustGoJava.NETC++Swift
-
Create new window, returns new
Window.By default, this will make the window active. For the new window to be created and not set to current, pass in
attach=False.- Parameters
-
-
start_directory ( StrPath | None ) – working directory in which the new window is created.
-
attach ( bool ) – make new window the current window after creating it, default True.
-
window_index ( str ) – create the new window at the given index position. Default is empty string which will create the window in the next available position.
-
window_shell ( str | None ) – execute a command on starting the window. The window will close when the command exits. When this command exits the window will close. This feature is useful for long-running processes where the closing of the window upon completion is desired. Note:
-
direction ( WindowDirection | None ) – Insert window before or after target window.
-
target_window ( str | None ) – Used by
Window.new_windowto specify the target window. -
kill_existing ( bool | None ) – Destroy the window at the target index if it already exists (
-kflag). added 0.56 -
select_existing ( bool | None ) – If a window with the given name already exists, select it instead of creating a new one (
-Sflag). added 0.56
-
- Returns
-
WindowThe newly created window.
In other ports Create a window
- Ruby
LibTmux::Session#new_window - Lua
libtmux.Session:new_window - TypeScript
session.Session.newWindow - Rust
session.Session.new_window - Go
tmux.Session.NewWindow - Java
io.github.libtmux.Session.Session.newWindow - .NET
LibTmux.Session.CreateWindowAsync - C++
libtmux::Session::new_window - Swift
Server.newWindow(in:named:startDirectory:)
Examples
>>> window_initial = session.new_window(window_name='Example')>>> window_initialWindow(@... 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_beforeWindow(@... 1:Window before, Session($1 libtmux_...))>>> window_initialWindow(@... 3:Example, Session($1 libtmux_...))>>> window_after = session.new_window(... window_name='Window after', direction=WindowDirection.After)>>> window_initial.refresh()>>> window_after.refresh()>>> window_afterWindow(@... 3:Window after, Session($1 libtmux_...))>>> window_initialWindow(@... 4:Example, Session($1 libtmux_...))>>> window_beforeWindow(@... 1:Window before, Session($1 libtmux_...))const created = await session.newWindow({ name: "editor" });created.name; // "editor"0 declared, 0 inherited