Core Library0.xAPI Reference

Choose documentation 3

v0.1.1

Current version

v0.1.1
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-ruby v0.1.1

Session.new_window

Behavior: Creation.

Source and package
Qualified name
LibTmux::Session#new_window
Module
LibTmux
Declared in
Session
Package
libtmux
Source
gems/libtmux/lib/libtmux/entity.rb
Other languages
PowerShell Julia Elixir PythonLuaTypeScriptRustGoJavaC#C++SwiftKotlinScala F#
def new_window: ( name: ::String, command: ::Array[::String], receipt: true, ?index: ::Integer?, ?cwd: ::String?, ?environment: ::Hash[::String, ::String], ?focus: bool, ?timeout: ::Numeric, ?cancel: untyped ) -> ::LibTmux::CreationReceiptdef new_window: ( name: ::String, command: ::Array[::String], ?receipt: false, ?index: ::Integer?, ?cwd: ::String?, ?environment: ::Hash[::String, ::String], ?focus: bool, ?timeout: ::Numeric, ?cancel: untyped ) -> ::LibTmux::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/cat and /bin/sh available. In an empty directory, save this Gemfile:

source "https://rubygems.org"
gem "libtmux", "0.1.1"

Save this complete program as new_window.rb. Its Server.start() block owns a private tmux server and stops it on exit, including after an error. View source

# frozen_string_literal: true
begin
# docs:begin main
require "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 main
rescue StandardError => error
warn "#{error.class}: #{error.message}"
exit 1
end

Install the gem and run the program. An operation or cleanup error makes it exit unsuccessfully:

Terminal window
$ bundle install && \
bundle exec ruby new_window.rb

Expected output:

window: logs
session windows: 2
Parameters
  • name (::String) #

  • command (::Array[::String]) #

  • receipt (true) # for new_window(name, command, receipt, index, cwd, environment, focus, timeout, cancel) [overload 1]

  • index (::Integer?) #

  • cwd (::String?) #

  • environment (::Hash[::String, ::String]) #

  • focus (bool) #

  • timeout (::Numeric) #

  • cancel (untyped) #

  • receipt (false) # for new_window(name, command, receipt, index, cwd, environment, focus, timeout, cancel) [overload 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

Esc

Type to search.

Reference previewOpen reference