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

Server.Panes

Panes materializes pane records for every winlink. Failures, including ErrNoServer, remain errors rather than empty results.

Source and package
Qualified name
tmux.Server.Panes
Package
tmux
Declared in
Server
Distribution
github.com/libtmux/libtmux-go/tmux
Source
tmux/hierarchy.go
Other languages
Perlmethod Erlangfunction PowerShellcmdlet Juliafunction Elixirfunction Haskell Common Lispfunction PythonRubyLuaTypeScriptRustJavaC#C++SwiftKotlinScalaOCamlF#function Clojurefunction
func (s Server) Panes(ctx context.Context) ([]Pane, error)

Examples#

List pane records across every session and window on a private server. Panes materializes each linked view, so callers that link windows may see the same underlying pane ID in more than one session. Use Go 1.26 or newer and tmux 3.3a or newer on a Unix system, with tmux and cat on PATH. In a new directory, create a module and add the library from the Go module proxy:

Terminal window
$ go mod init example.com/libtmux-api && \
go get github.com/libtmux/libtmux-go@latest

Save this complete example as example_test.go. It creates a private temporary socket and stops its server before removing the directory. Cleanup failure fails the example and retains the socket directory. View source

package tmux_test
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"time"
"github.com/libtmux/libtmux-go/tmux"
)
// List pane records across every session and window on a private server.
// Panes materializes each linked view, so callers that link windows may see
// the same underlying pane ID in more than one session.
func ExampleServer_Panes_complete() {
run := func() (runErr error) {
directory, err := os.MkdirTemp("", "libtmux-go-api-")
if err != nil {
return fmt.Errorf("create socket directory: %w", err)
}
server, err := tmux.NewServer(tmux.ServerOptions{
SocketPath: filepath.Join(directory, "tmux.sock"),
ConfigFile: "/dev/null",
})
if err != nil {
return errors.Join(err, os.RemoveAll(directory))
}
defer func() {
// Cleanup has its own deadline because the operation may have timed out.
cleanup, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := server.Kill(cleanup); err != nil && !errors.Is(err, tmux.ErrNoServer) {
runErr = errors.Join(runErr, fmt.Errorf("stop server at %s: %w", directory, err))
return
}
runErr = errors.Join(runErr, os.RemoveAll(directory))
}()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
for _, name := range []string{"work", "docs"} {
if _, err = server.NewSession(ctx, tmux.NewSessionRequest{
Name: name, WindowName: name + "-editor", Command: "cat", Width: 100, Height: 30,
}); err != nil {
return fmt.Errorf("create %s session: %w", name, err)
}
}
panes, err := server.Panes(ctx)
if err != nil {
return fmt.Errorf("list panes: %w", err)
}
for _, pane := range panes {
if pane.ID() == "" {
return errors.New("pane has no stable ID")
}
}
fmt.Println("panes:", len(panes))
return nil
}
if err := run(); err != nil {
panic(err)
}
// Output:
// panes: 2
}

Run the saved file. Go checks the Output comment and fails on different output or an operation or cleanup error:

Terminal window
$ go test -count=1 -v example_test.go
Parameters

Guides#

Pages that discuss Panes.

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