On this page
server.Server.new_session
- Module
- server
- Declared in
- Server
- Package
- libtmux
- Source
- crates/libtmux/src/server.rs
- Other languages
- PythonTypeScriptGoJava.NETC++Swift
- new_session ( self , options : impl Into<NewSessionOptions> ) Result<Session, Error>
-
Create a detached session and return it.
The session is always detached: attaching would take over the calling process's terminal, which a library must not do on its own initiative.
tmux prints the new session through the same format machinery as a listing, so this costs one round trip rather than a create followed by a lookup.
tmux expands the name as a format before it checks it, so
#(command)in one runs a shell command. See [the crate documentation][crate#a-name-reaches-tmux-as-a-format] before passing text a caller supplied.Errors
Returns an error when tmux refuses the command, which includes a name that already exists, and when its output cannot be decoded.
In other languages 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