Server.new_session
Behavior: Creation.
Source and package
- def new_session: ( name: ::String, command: ::Array[::String], receipt: true, ?width: ::Integer?, ?height: ::Integer?, ?window
_name : ::String?, ?cwd: ::String?, ?environment: ::Hash[::String, ::String], ?timeout: ::Numeric, ?cancel: untyped ) -> ::LibTmux:: def new_session: ( name: ::String, command: ::Array[::String], ?receipt: false, ?width: ::Integer?, ?height: ::Integer?, ?windowCreation Receipt _name : ::String?, ?cwd: ::String?, ?environment: ::Hash[::String, ::String], ?timeout: ::Numeric, ?cancel: untyped ) -> ::LibTmux:: Session -
Description#
Behavior contract: Creation.
Examples#
Start a private server and create a session. Request a creation receipt to read the session, window, and pane IDs returned by that creation command. Use Ruby 3.3 or newer with Bundler, and tmux 3.3a or newer, on Unix with
/bin/catand/bin/shavailable. In an empty directory, save thisGemfile:source "https://rubygems.org"gem "libtmux", "0.1.1"Save this complete program as
new_session.rb. ItsServer.start()block owns a private tmux server and stops it on exit, including after an error. View source# frozen_string_literal: truebegin# docs:begin mainrequire "libtmux"LibTmux::Server.start do |server|created = server.new_session(name: "work", window_name: "main", command: ["/bin/cat"], receipt: true)puts "session: #{created.entity.id}"puts "window: #{created.window.id}"puts "pane: #{created.pane.id}"end# docs:end mainrescue StandardError => errorwarn "#{error.class}: #{error.message}"exit 1endInstall the gem and run the program. An operation or cleanup error makes it exit unsuccessfully:
Terminal window $ bundle install && \bundle exec ruby new_session.rbExpected output:
session: $0window: @0pane: %0- Parameters
-
-
receipt(true) # fornew_session(name, command, receipt, width, height, window_name, cwd, environment, timeout, cancel) [overload 1] -
window_name(::String?) # -
environment(::Hash[::String, ::String]) # -
receipt(false) # fornew_session(name, command, receipt, width, height, window_name, cwd, environment, timeout, cancel) [overload 2]
tmux command#
The tmux commands behind 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 |
|---|---|
| Python | libtmux |
| Lua | libtmux |
| TypeScript | server |
| Rust | server |
| Go | tmux |
| Java | io |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| C++ | libtmux:: |
| Swift | Server |
No equivalent is recorded in PowerShell, Julia, Elixir or F#.