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

Server.panes()

Every pane on this server, in tmux's own order. A pane whose window has several session links appears once.

Source and package
Qualified name
Server.panes()
Declared in
Server
Package
libtmux-swift
Source
Sources/LibTmux/Server.swift
Other languages
Perlmethod Erlangfunction PowerShellcmdlet Juliafunction Elixirfunction Haskell Common Lispfunction PythonRubyLuaTypeScriptRustGoJavaC#C++KotlinScalaOCamlF#function Clojurefunction
panes() -> [Pane]

Examples#

Find a window's panes. Read all panes and select those whose windowID matches a newly created window. Pane values are snapshots; reading a property does not query tmux again. Use Swift 6.2 or newer and tmux 3.3a or newer on Linux or macOS. In an empty directory, save this consumer package as Package.swift; SwiftPM fetches the library from release 0.1.1:

// swift-tools-version: 6.2
import PackageDescription
let package = Package(
name: "ApiExample",
platforms: [.macOS(.v13)],
dependencies: [
.package(url: "https://github.com/libtmux/libtmux-swift.git", from: "0.1.1")
],
targets: [
.executableTarget(
name: "ApiExample",
dependencies: [
.product(name: "LibTmux", package: "libtmux-swift"),
.product(name: "TmuxFixture", package: "libtmux-swift"),
],
path: "Sources"
)
]
)

Create a Sources directory and save this complete program as Sources/Example.swift. The withTmuxServer fixture owns a private tmux server and stops it after success or failure. Ordinary application code uses Server for its own socket; these examples use the fixture until their setup moves to ordinary server objects. View source

import Foundation
import LibTmux
import TmuxFixture
@main
struct ApiPanes {
static func main() async {
do {
try await withTmuxServer { @Sendable server in
let session = try await server.newSession(named: "work")
let appearance = try await server.newWindow(in: session, named: "logs")
let panes = try await server.panes()
let logPanes = panes.filter { $0.windowID == appearance.window.id }
print("Log panes: \(logPanes.count)")
for pane in logPanes {
print("Active: \(pane.isActive)")
}
}
} catch {
FileHandle.standardError.write(Data("Example failed: \(error)\n".utf8))
exit(EXIT_FAILURE)
}
}
}

Build and run the saved program. An operation or cleanup error produces a failing exit status. Set LIBTMUX_TMUX_BIN to an absolute executable path to select a tmux version:

Terminal window
$ swift run ApiExample

Expected output:

Log panes: 1
Active: true
Raises

tmux command#

The tmux commands behind panes().

tmux C API#

The C declarations in tmux that implement these commands.

In other ports#

List the server's panes

Equivalents of List the server's panes in other languages
Language Equivalent
Python libtmux.Server.panes
Ruby LibTmux::Server#list_panes
Lua libtmux.Snapshot.panes
PowerShell LibTmux\Get-TmuxPane Use the -Server parameter set to acquire panes across the server.
Julia LibTmux.panes panes with a Snapshot reads every captured physical pane. Use paneoccurrences for session placements.
Erlang tmux_snapshot:panes/1 Returns unique captured physical panes without tmux I/O.
Elixir LibTmux.Snapshot.panes/1 Returns a Selection of every captured physical pane without contacting tmux.
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
Common Lisp libtmux:panes panes on a snapshot returns captured physical panes once each.
TypeScript server.Server.panes
Rust server.Server.panes
Go tmux.Server.Panes
Java io.github.libtmux.Server.panes
Clojure libtmux.core/panes! Acquires a new graph and returns its pane occurrences.
Kotlin io.github.libtmux.kotlin.Server.panes
Scala io.github.libtmux.scaladsl.Server.panes
C# LibTmux.Server.Panes
F# LibTmux.FSharp.Server.panes Builds a deferred pane query on the shared .NET LibTmux.Server. Query.list acquires panes across that server.
C++ libtmux::Server::panes
OCaml Libtmux.Snapshot.panes
Perl LibTmux::Snapshot::panes One entry per captured physical pane; raw listings preserve contextual rows separately.
Esc

Type to search.

Reference previewOpen reference