Server.new_session
Create new session, returns new Session.
Source and package
-
Description#
Uses
-Pflag to print session info,-Ffor return formatting returns new Session object.$ tmux new-session -dwill create the session in the background$ tmux new-session -Adwill 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
-
-
session_name(str | None) # – :: $ tmux new-session -s <session_name> -
attach(bool) # – create session in the foreground.attach=Falseis equivalent to:: $ tmux new-session -d -
start_directory(StrPath | None) # -
window_name(str | None) # -
window_command(str | None) # -
detach_others(bool | None) # -
client_flags(str | None) #
-
- Returns
- 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
cmd_new_session_exec - calls → 2
spawn_window - calls → 3
spawn_pane - calls → 4
window_add_pane - calls → 5
window_pane_create
In other ports#
Create a session
| Language | Equivalent |
|---|---|
| Ruby | Lib |
| Lua | libtmux |
| Erlang | tmux |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | server |
| Rust | server |
| Go | tmux |
| Java | io |
| Clojure | libtmux |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| C++ | libtmux:: |
| Swift | Server |
| OCaml | Libtmux |
| Perl | Lib 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#.