# LibTmux::Window#list_panes

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Ruby
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ruby/blob/da7b6191b9439e3c84fa1c9eeaa9168263ee7af4/gems/libtmux/lib/libtmux/entity.rb#L122
- **Page:** https://libtmux.org/en/ruby/v0.1.1/reference/libtmux-window-list_panes/

```
def list_panes: (
  ?timeout: ::Numeric,
  ?cancel: untyped
) -> ::Array[::LibTmux::Pane]
```

Behavior: Live acquisition.

Behavior contract: Live acquisition.

## Examples

List panes across the server, within one session, and within one window. 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`:

```ruby
source "https://rubygems.org"

gem "libtmux", "0.1.1"
```

Save this complete program as `list_panes.rb`. Its `Server.start` block owns a private tmux server and stops it on exit, including after an error.

[Source example](https://github.com/libtmux/libtmux-ruby/blob/da7b6191b9439e3c84fa1c9eeaa9168263ee7af4/examples/api/list_panes.rb).

```ruby
# frozen_string_literal: true

require "libtmux"

begin
  LibTmux::Server.start do |server|
    work = server.new_session(name: "work", command: ["/bin/cat"], receipt: true)
    work.pane.split(direction: :horizontal, command: ["/bin/cat"])
    server.new_session(name: "other", command: ["/bin/cat"])
    puts "server panes: #{server.list_panes.length}"
    puts "work panes: #{work.entity.list_panes.length}"
    puts "window panes: #{work.window.list_panes.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:

```console
$ bundle install && \
  bundle exec ruby list_panes.rb
```

Expected output:

```text
server panes: 3
work panes: 2
window panes: 2
```

## Parameters

- `timeout` (`::Numeric`)
- `cancel` (`untyped`)

## tmux command

The tmux commands behind `list_panes`.

- [`list-panes`](/en/tmux/latest/manual/list-panes/) `-t` window scope, [`cmd_list_panes_window`](/en/tmux/latest/reference/c-function-cmd-list-panes-c-cmd_list_panes_window/) (source: `gems/libtmux/lib/libtmux/server.rb:470`)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_list_panes_entry`](/en/tmux/latest/reference/c-variable-cmd_list_panes_entry/) (attribute)
- [`cmd_list_panes_window`](/en/tmux/latest/reference/c-function-cmd-list-panes-c-cmd_list_panes_window/) (function)

## In other ports

List a window's panes

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Window.panes`](/en/py/latest/reference/libtmux-window-panes/) (property) |
| PowerShell | [`LibTmux\Get-TmuxPane`](/en/powershell/latest/reference/libtmux-get-tmuxpane/) (cmdlet). Use the [`-Window`](/en/powershell/latest/reference/libtmux-get-tmuxpane/#LibTmux%5CGet-TmuxPane.parameter.Window) parameter set to acquire panes in one window. |
| Julia | [`LibTmux.panes`](/en/julia/latest/reference/libtmux-panes/) (function). `panes` with a captured `WindowSnapshot` reads panes in that window; missing coverage is an error. |
| TypeScript | [`window.Window.panes`](/en/ts/latest/reference/window-window-panes/) (method) |
| Rust | [`window.Window.panes`](/en/rs/latest/reference/window-window-panes/) (method) |
| Go | [`tmux.Window.Panes`](/en/go/latest/reference/tmux-window-panes/) (method) |
| Java | [`io.github.libtmux.Window.panes`](/en/java/latest/reference/io-github-libtmux-window-window-panes/) (method) |
| Kotlin | [`io.github.libtmux.kotlin.Window.panes`](/en/kotlin/latest/reference/io-github-libtmux-kotlin-window-panes/) (property) |
| Scala | [`io.github.libtmux.scaladsl.Window.panes`](/en/scala/latest/reference/io-github-libtmux-scaladsl-window-panes/) (method) |
| C# | [`LibTmux.Window.Panes`](/en/csharp/latest/reference/libtmux-window-panes/) (property) |
| F# | [`LibTmux.FSharp.Window.panes`](/en/fsharp/latest/reference/libtmux-fsharp-window-panes/) (function). Builds a deferred pane query from one `LibTmux.Window` and its server. `Query.list` acquires panes scoped to that window ID. |
| C++ | [`libtmux::Window::panes`](/en/cxx/latest/reference/libtmux-window-panes/) (method) |
| Swift | [`Snapshot.panes(of:)`](/en/swift/latest/reference/snapshot-panes(of-)/) (method) |

No equivalent is recorded in Lua or Elixir.
