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.

MoreLess about this notice

class libtmux-dotnet

Session

Represents an immutable session handle and snapshot.

Source and package
Qualified name
LibTmux.Session
Namespace
LibTmux
Package
LibTmux
Source
src/LibTmux/Session.cs
class LibTmux.Session

Description

Thread-safe: the handle is immutable once constructed and may be shared freely, including as a singleton. Every mutating call answers a new handle rather than changing this one.

What is on here

A tmux session holds windows and has a good many members of its own. They fall into a few groups:

Reaching a session
Read one from the server by identifier, or ask for the session holding the pane this process runs in. That one is resolved through the pane rather than the session id in TMUX, which is frozen at pane spawn and names the wrong session once the pane's window is moved or linked elsewhere.
Identity and state
A handle carries what tmux reported when it was made, so reading its name, attachment, or fields is local and never reaches tmux; re-read the session to see current state. Two handles are equal when they name the same session on the same server generation. The control client this library keeps on the server does not count as attached.
Identity
Owner
Re-read
Looking inside
Read this session's windows or panes from tmux, or hand tmux an UnsafeTmuxFilter to keep only some of them. The captured relations hold what a capture found instead: reading them never reaches tmux, and one the capture did not read stays uncaptured. Reading the active pane from tmux gets the pane the session shows now, and throws TmuxObjectNotFoundException when tmux reports none.
Captured
Finding a window
Read one window of this session, by typed identifier or by a string target. The Get methods throw TmuxObjectNotFoundException when this session has no such window; the Find methods answer null, including for a target that names a window in another session. A string target also accepts a window name, which two windows can share.
Get by identifier
Get by target
Find by identifier
Find by target
Windows
Create a window in this session, or create one inside a scope that stops it when disposed. The receipt form also returns the first pane's identifier from the same creation reply, and throws ArgumentException when the request may select an existing window, since an existing window has no creation receipt. Selecting a window, or stepping to the next, previous, or last one, answers the window that is active afterwards; stopping a window with no target stops the active one.
Changing the session
Renaming answers a replacement handle carrying the new name, and tmux expands the name as a format, so a # in it does not survive verbatim. Stopping a session can stop every other session instead, or its whole group. Group stopping needs tmux 3.7: older servers reject the flag, so against them the request is logged and the flag omitted, and this session stops while its group siblings do not.
Clients
Attaching inherits the caller's terminal on stdin and waits for detach, and needs a positive acknowledgement within five seconds. Switching moves the current client to this session, and detaching detaches every client attached to it. Holding the control client that waits on this session's panes saves an attach for each wait in a series, while tmux still lists the held client among the session's clients.
Options and hooks
The session's options, its hooks, and the environment panes created in it inherit are objects of their own: TmuxOptions, TmuxHooks, and TmuxEnvironment.

Anything tmux can do to a session that is not here is reachable through ExecuteCommandAsync(), which runs one raw command against this session.

Properties13

Session properties
NameTypeDescription
Server Server Gets the server that owns this session.
Windows CapturedRelation<Window> Gets the windows the capture found in this session.
Panes CapturedRelation<Pane> Gets the panes the capture found in this session.
Hooks TmuxHooks Gets the hooks of this session.
Id SessionId Gets the session identifier.
Name string Gets the session name captured with this handle.
Attached bool Gets whether a client was attached when this session was read.
Options TmuxOptions Gets the options of this session.
Environment TmuxEnvironment Gets the environment panes created in this session inherit from.
ActiveWindow CapturedValue<Window> Gets the captured active window, or an uncaptured relation.
ActivePane CapturedValue<Pane> Gets the captured active pane, or an uncaptured relation.
Generation ServerGeneration Gets the server generation captured with this session.
RawFormatFields IReadOnlyDictionary<string, string?> Gets the tmux fields captured when this handle materialized.

Members27 members

Collections and queries4

Common operations13

Other members10

Order: the accessors that walk the hierarchy, the operations the ports share, then the rest.

Guides

task material

Pages that discuss Session.

In other ports

task equivalence 22 other ports mapped

Source-verified mappings for A tmux session. A mapping says these APIs perform the same task. It does not say they share defaults, errors or completion: check each page.

A tmux session in each port
PortAPIDiffers from C#
C# LibTmux.Session
Represents an immutable session handle and snapshot.
This page
Python libtmux.Session
tmux(1) Session [session_manual].
None recorded in the model
Ruby LibTmux::Session None recorded in the model
Lua libtmux.Session None recorded in the model
PowerShell LibTmux\Get-TmuxSession
Read sessions with optional exact selectors.
This cmdlet reads and returns shared .NET LibTmux.Session objects. Child windows and panes require further acquisition.
Julia LibTmux.SessionSnapshot 2 overloads
SessionSnapshot holds captured session data. Actions use its SessionRef, a typed identity bound to an observed daemon generation.
Erlang #tmux_model:session{} None recorded in the model
Elixir LibTmux.Session
An immutable session observation. Attachment retains tmux's client count.
Session is an immutable observation. Fields not captured read as :unloaded.
Haskell LibTmux.Snapshot.Session
Detached physical session. Navigate its appearances through WindowLink.
Session is a detached physical session. WindowLink records each placement of a window in it, and operations take a generation-bound SessionRef.
Common Lisp libtmux:session
A captured physical tmux session.
session is an immutable captured entity. The same name also has a relation accessor with a distinct public identity.
TypeScript session.Session
One session on one tmux server, as a handle rather than a copy of it.
None recorded in the model
Rust session.Session
One tmux session, together with the snapshot it was discovered with.
None recorded in the model
Go tmux.Session
Session is one materialized tmux session record. It is normally returned by Server.Snapshot, Server.Session, or Session.Refresh. A zero Session is not a usable tmux target.
None recorded in the model
Java io.github.libtmux.Session
One tmux session, as one capture saw it.
readonly
Clojure libtmux.core/sessions!
Acquires captured sessions; acquisition failure throws.
Acquires a vector of captured session maps. The session value is a map, not a wrapper class.
Kotlin io.github.libtmux.kotlin.Session
A tmux session and its captured windows and properties.
None recorded in the model
Scala io.github.libtmux.scaladsl.Session
A captured session, opaque over the Java handle; every operation beyond equality is an extension, generated from the operation catalog or handwritten where the catalog marks it WAIT, STREAM or LIFECYCLE.
2 overloads
F# LibTmux.FSharp.Session
Starts queries confined to one session.
This F# module builds deferred child queries from a shared .NET LibTmux.Session and its server association. Query.list acquires their results from tmux.
C++ libtmux::Session
One session, as one listing saw it.
None recorded in the model
Swift Session
A tmux session, as it was when the listing was read.
None recorded in the model
OCaml Libtmux.Session.t None recorded in the model
Perl LibTmux::Session
Captured session entity
A captured read-only entity; explicit Server operations accept its stable identity.
Raku LibTmux::Model::Session
Captured session with local window-link and group relationships.
None recorded in the model
Esc
Search in

Type to search.

Reference previewOpen reference