Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

Python API

Python documentation

View as Markdown

Module
libtmux
Declared in
Server
Package
libtmux
Source
src/libtmux/server.py
Other languages
RubyLuaTypeScriptRustGoJava.NETC++Swift
new_session
( 15 parameters ) ( self , session_name : str | None = None , kill_session : bool = False , attach : bool = False , start_directory : StrPath | None = None , window_name : str | None = None , window_command : str | None = None , x : int | DashLiteral | None = None , y : int | DashLiteral | None = None , environment : dict[str, str] | None = None , args : t.Any , detach_others : bool | None = None , no_size : bool | None = None , client_flags : str | None = None , kwargs : t.Any )
→ Session
method [source]
method [source]
new_session

Create new session, returns new Session .

Uses -P flag to print session info, -F for return formatting returns new Session object.

$ tmux new-session -d will create the session in the background $ tmux new-session -Ad will move to the session name if it already exists. todo: make an option to handle this.

Parameters
  • session_name ( str | None ) – :: $ tmux new-session -s <session_name>

  • attach ( bool ) – create session in the foreground. attach=False is equivalent to:: $ tmux new-session -d

Returns

Session

Raises
In other ports Create a session

Examples

Sessions can be created without a session name (0.14.2+):

>>> server.new_session()
Session($2 2)

Creating them in succession will enumerate IDs (via tmux):

>>> server.new_session()
Session($3 3)

With a session_name :

>>> server.new_session(session_name='my session')
Session($4 my session)
const created = await server.newSession({ name: "work" });
created.name; // "work"

0 declared, 0 inherited

Esc

Type to search.