Core LibrarystableAPI Reference

Choose documentation 3

stable

Current version

stable
English

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

Python API

method libtmux stable

Server.new_session

Create new session, returns new Session .

Source and package
Qualified name
libtmux.Server.new_session
Module
libtmux
Declared in
Server
Package
libtmux
Source
src/libtmux/server.py
Other languages
PowerShell Julia RubyLuaTypeScriptRustGoJavaC#C++SwiftKotlinScala F#
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

Description#

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.

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)
Parameters
Returns

Session

Raises

tmux command new-session

In other ports Create a session
Esc

Type to search.

Reference preview Open reference