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.list_windows

Behavior: Live acquisition.

Source and package
Qualified name
LibTmux::Session#list_windows
Module
LibTmux
Declared in
Session
Package
libtmux
Source
gems/libtmux/lib/libtmux/entity.rb
Other languages
PowerShellcmdlet Juliafunction Elixir Python Lua TypeScriptRustGoJavaC#C++SwiftKotlinScalaF#function
def list_windows: ( ?timeout: ::Numeric, ?cancel: untyped ) -> ::Array[::LibTmux::Window]

Description#

Behavior contract: Live acquisition.

Examples#

List all server windows and the windows belonging to one session. 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 list_windows.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
require "libtmux"
begin
LibTmux::Server.start do |server|
work = server.new_session(name: "work", command: ["/bin/cat"])
work.new_window(name: "logs", command: ["/bin/cat"])
server.new_session(name: "other", command: ["/bin/cat"])
puts "server windows: #{server.list_windows.length}"
puts "work windows: #{work.list_windows.length}"
end
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 list_windows.rb

Expected output:

server windows: 3
work windows: 2
Parameters

tmux command#

The tmux commands behind list_windows.

tmux C API#

The C declarations in tmux that implement these commands.

In other ports#

List a session's windows

Equivalents of List a session's windows in other languages
Language Equivalent
Python libtmux.Session.windows
PowerShell LibTmux\Get-TmuxWindow Use the -Session parameter set to acquire placements in one session.
Julia LibTmux.windows windows() with a captured SessionSnapshot reads distinct physical windows in that session. Use windowlinks() for placements.
TypeScript session.Session.windows
Rust session.Session.windows
Go tmux.Session.Windows
Java io.github.libtmux.Session.windows
Kotlin io.github.libtmux.kotlin.Session.windows
Scala io.github.libtmux.scaladsl.Session.windows
C# LibTmux.Session.Windows
F# LibTmux.FSharp.Session.windows Builds a deferred window query from one LibTmux.Session and its server. Query.list() acquires placements scoped to that session ID.
C++ libtmux::Session::windows
Swift Snapshot.windows(of:)

No equivalent is recorded in Lua or Elixir.

Esc

Type to search.

Reference previewOpen reference