Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux latest

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
Perlmethod Erlang PowerShell Julia Elixir Haskell Common Lisp RubyLuaTypeScriptRustGoJavaC#C++SwiftKotlinScalaOCaml F# Clojure
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#

The tmux commands behind new_session.

kill-session (kill_session is true, session exists) new-session

tmux C API#

The C declarations in tmux that implement these commands.

Each path starts at a function a command runs, which is degree 1. The degree counts steps from there along the path, and each step is a call or a reference: degree 2 is reached from that function, degree 3 from the next, and so on.

Create a session and its first pane

  1. 1 cmd_new_session_exec
  2. calls → 2 spawn_window
  3. calls → 3 spawn_pane
  4. calls → 4 window_add_pane
  5. calls → 5 window_pane_create

In other ports#

Create a session

Equivalents of Create a session in other languages
Language Equivalent
Ruby LibTmux::Server#new_session
Lua libtmux.Server:new_session
Erlang tmux_session:create/2
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
TypeScript server.Server.newSession
Rust server.Server.new_session
Go tmux.Server.NewSession
Java io.github.libtmux.Server.newSession
Clojure libtmux.core/new-session!
Kotlin io.github.libtmux.kotlin.Server.newSession
Scala io.github.libtmux.scaladsl.Server.newSession
C# LibTmux.Server.CreateSessionAsync
C++ libtmux::Server::new_session
Swift Server.newSession(named:startDirectory:windowName:width:height:environment:shell:)
OCaml Libtmux_unix.Client.create_session
Perl LibTmux::Server::new_session Explicit Server operation. Captured entities remain local observations; use a new snapshot to observe changes.

No equivalent is recorded in PowerShell, Julia, Elixir, Common Lisp or F#.

Esc

Type to search.

Reference previewOpen reference