Core Library0.xGuides

Choose documentation 2

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.

MoreLess about this notice

Read tmux objects

Needs libtmux for PowerShell 0.x Install

The cmdlets return native objects from libtmux for .NET. Inspect them with Get-Member, select their properties and pass them to other cmdlets.

Choose a server

Create an endpoint with New-TmuxServer -SocketPath or -SocketName, then pipe it to a read command. Creating it does no I/O.

  • No socket parameter: tmux picks the server: the one TMUX names inside a tmux pane, otherwise its default socket.
  • Environment: LIBTMUX_SOCKET_PATH (-S) or LIBTMUX_SOCKET (-L) chooses a socket for such an endpoint, the path first. A blank value counts as unset, and a parameter beats both. The endpoint reads them when it is made.
  • Connect-TmuxServer: discovers an unmaterialized endpoint and returns its connected replacement. A connected handle is returned unchanged.
CommandTyped owner accepted from the pipelineOutput
Connect-TmuxServerLibTmux.ServerLibTmux.Server
Get-TmuxSnapshotLibTmux.ServerReplacement LibTmux.Server
Get-TmuxSessionLibTmux.ServerLibTmux.Session objects
Get-TmuxWindowLibTmux.Server or LibTmux.SessionLibTmux.Window objects
Get-TmuxPaneLibTmux.Server, LibTmux.Session, or LibTmux.WindowLibTmux.Pane objects

These commands read tmux explicitly.

Select objects

  • -Id selects a literal tmux identifier, such as $0, @1 or %2. Use single quotes for a session ID.
  • -Name is also accepted by session and window commands.
  • Selectors compare ordinally and distinguish case. They do not expand wildcards, and combined selectors must all match.
  • An unmatched selector emits no objects and is not an error. Wrap a pipeline in @(...) when its count matters.
  • Owners bind by their native type. Property names on another object do not bind from the pipeline.
  • Tab completion for -Name and -Id offers values from a captured server, session or window, never from tmux. Capture first with Get-TmuxSnapshot; an uncaptured owner offers none. The command still checks current state when you run it.

For more filtering, use Where-Object after acquisition. For reusable criteria, use New-TmuxQuery with the local Select-TmuxPane, Select-TmuxWindow or Select-TmuxSession. Get-TmuxQueryField lists the fields.

For a fresh query, pass an endpoint and a query document to Invoke-TmuxQuery. It emits matching native objects; -AsResult keeps the result and its complete captured graph, including an empty selection. Get-TmuxQueryPlan shows source evaluation, local residuals and fallback reasons before execution, with no I/O. The query guide has the details.

Snapshots

Get-TmuxSnapshot defaults to -Depth Panes. Shallower depths are Server, Sessions, and Windows. It returns a replacement graph and leaves the input handle and earlier snapshots unchanged. Even -Depth Server performs a fresh, generation-guarded read.

  • Metadata: SnapshotMetadata records the depth, daemon generation, UTC start and end readings, and monotonic Elapsed time. UTC can move backwards if the clock is adjusted; use Elapsed for duration.
  • Not atomic: a snapshot spans several tmux commands. Contradictory parent, child-count or active-child observations fail with InconsistentSnapshotException and emit no graph. Equal-count changes can escape detection. The command never retries.
  • Uncaptured data: uncaptured relations report IsCaptured = false and throw when enumerated. A field that was not captured raises IncompleteSnapshotException; a captured empty string or null keeps its value. Property access never reads tmux.
  • After the daemon exits: captured panes expose CurrentCommand and CurrentPath, and formatting and Get-Member keep working. They do not refresh objects.
  • Parents: captured children keep their root through Server, and parent properties return the captured instances when that depth is available.
  • Placement: a pane’s Window keeps its session and index placement, including repeated links to the same window. Window.LinkedSessions lists each related session once.
  • Active children: Session.ActiveWindow, Session.ActivePane and Window.ActivePane return CapturedValue<T>. Check IsCaptured, then read Value. Reading an unavailable Value raises IncompleteSnapshotException; OrNull() returns null instead. Active properties use the IDs from their own parent’s row, so separate reads can record different selections.
  • Filtering: filtering a collection changes only which items are selected. Traversing their parents still reaches the complete captured children.
  • Refresh: Update-TmuxPane refreshes one pane’s fields. Its parent navigation does not borrow data from an older graph. Take another snapshot for a new graph.

Default tables show native identifiers, captured names or titles, and owner context. A handle resolved only by identifier shows blank columns for fields it has not captured, and the views tell that apart from other failures.

Errors

A read failure writes an error for the affected owner, including an endpoint with no running server, and later owners in the pipeline continue. Use -ErrorAction Stop to terminate instead.

Error IDs are Tmux.ConnectFailed, Tmux.SnapshotFailed, Tmux.SessionReadFailed, Tmux.WindowReadFailed and Tmux.PaneReadFailed. The error record keeps the core exception and its dispatch metadata when it has them. Cancelling the pipeline cancels the pending core operation, and borrowed server handles do not own the daemon’s lifetime.

Esc
Search in

Type to search.

Reference previewOpen reference