Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
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 latest

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
Perlmethod Erlang PowerShell Julia Elixir Haskell Common Lisp PythonLuaTypeScriptRustGoJavaC#C++SwiftKotlinScalaOCaml F# Clojure
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.2"

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

Equivalents of Create a window in other languages
Language Equivalent
Python libtmux.Session.new_window
Lua libtmux.Session:new_window
Erlang tmux_window:create/2
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
TypeScript session.Session.newWindow
Rust session.Session.new_window
Go tmux.Session.NewWindow
Java io.github.libtmux.Session.newWindow
Clojure libtmux.core/new-window!
Kotlin io.github.libtmux.kotlin.Session.newWindow
Scala io.github.libtmux.scaladsl.Session.newWindow
C# LibTmux.Session.CreateWindowAsync
C++ libtmux::Session::new_window
Swift Server.newWindow(in:named:startDirectory:at:environment:shell:)
OCaml Libtmux_unix.Client.create_window
Perl LibTmux::Server::new_window 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#.

Esc

Type to search.

Reference previewOpen reference