Session.new_window
Behavior: Creation.
Source and package
- def new_window: ( name: ::String, command: ::Array[::String], receipt: true, ?index: ::Integer?, ?cwd: ::String?, ?environment: ::Hash[::String, ::String], ?focus: bool, ?timeout: ::Numeric, ?cancel: untyped ) -> ::Lib
Tmux:: def new_window: ( name: ::String, command: ::Array[::String], ?receipt: false, ?index: ::Integer?, ?cwd: ::String?, ?environment: ::Hash[::String, ::String], ?focus: bool, ?timeout: ::Numeric, ?cancel: untyped ) -> ::LibCreation Receipt Tmux:: Window -
Description#
Behavior contract: Creation.
Examples#
Create a named window in an existing session and read its name from a snapshot. 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_window.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|session = server.new_session(name: "work", command: ["/bin/cat"])window = session.new_window(name: "logs", command: ["/bin/cat"])puts "window: #{window.snapshot.name}"puts "session windows: #{session.list_windows.length}"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_window.rbExpected output:
window: logssession windows: 2
tmux command#
The tmux commands behind new_window.
tmux C API#
The C declarations in tmux that implement these commands.
Guides#
Pages that discuss new_window.
In other ports#
Create a window
| Language | Equivalent |
|---|---|
| Python | libtmux |
| Lua | libtmux |
| TypeScript | session |
| Rust | session |
| Go | tmux |
| Java | io |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| C++ | libtmux:: |
| Swift | Server |
No equivalent is recorded in PowerShell, Julia, Elixir or F#.