Session
Represents an immutable session handle and snapshot.
Source and package
- Qualified name
-
LibTmux. Session - Namespace
- LibTmux
- Package
- LibTmux
- Source
- src/LibTmux/Session.cs
-
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.
- IdentityStateOwnerRe-read
- Looking inside
- Read this session's windows or panes from tmux, or hand tmux an
UnsafeTmuxFilterto 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 throwsTmuxObjectNotFoundExceptionwhen tmux reports none. - Active
- Finding a window
- Read one window of this session, by typed identifier or by a string target. The Get methods throw
TmuxObjectNotFoundExceptionwhen this session has no such window; the Find methods answernull, 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 identifierGet by targetFind by identifierFind 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
ArgumentExceptionwhen 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. - SelectStop
- 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, andTmuxEnvironment.
Anything tmux can do to a session that is not here is reachable through
ExecuteCommandAsync(), which runs one raw command against this session.
Properties13
| Name | Type | Description |
|---|---|---|
| Server | Server | Gets the server that owns this session. |
| Windows | Captured | Gets the windows the capture found in this session. |
| Panes | Captured | Gets the panes the capture found in this session. |
| Hooks | Tmux | Gets the hooks of this session. |
| Id | Session | 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 | Tmux | Gets the options of this session. |
| Environment | Tmux | Gets the environment panes created in this session inherit from. |
| ActiveWindow | Captured | Gets the captured active window, or an uncaptured relation. |
| ActivePane | Captured | Gets the captured active pane, or an uncaptured relation. |
| Generation | Server | Gets the server generation captured with this session. |
| RawFormatFields | IRead | Gets the tmux fields captured when this handle materialized. |
Members27 members
Collections and queries4
- GetWindowsAsync Reads this session's windows from tmux.
- GetPanesAsync Reads this session's panes from tmux.
- SearchWindowsAsync Runs a tmux-side filter over this session's windows.
- SearchPanesAsync Runs a tmux-side filter over this session's panes.
Common operations13
- CreateWindowAsync Creates a window in this session.
- KillAsync Stops this session.
- RenameAsync Renames this session.
- DetachClientAsync Detaches every client attached to this session.
- RefreshAsync Re-reads this session from tmux.
- SelectNextWindowAsync Selects the next window.
- SelectPreviousWindowAsync Selects the previous window.
- SelectLastWindowAsync Selects the window that was last active.
- SelectWindowAsync Selects a window in this session.
- LockAsync Locks this session.
- FromEnvironmentAsync Returns the session holding the pane this process runs in.
- KillWindowAsync Stops one window in this session.
- SwitchClientAsync Switches the current client to this session.
Other members10
- AttachAsync Attaches a client to this session.
- CreateOwnedWindowAsync Creates a window in this session and takes ownership of it.
- CreateWindowWithReceiptAsync Creates a window and returns its initial pane identity.
- Equals
- ExecuteCommandAsync Executes one raw tmux command against this session.
- FindWindowAsync Reads one of this session's windows by identifier.
- GetActivePaneAsync Reads from tmux the pane this session shows: its current window's active pane.
- GetHashCode
- GetWindowAsync Reads one window in this session, throwing when it is absent.
- HoldWaitClientAsync Keeps the control client that waits on this session's panes use attached until the handle is disposed.
No members of Session match . The filter searches only this type. Search the whole API.
Order: the accessors that walk the hierarchy, the operations the ports share, then the rest.
Guides
task materialPages that discuss Session.
- Concepts
- Guides
In other ports
task equivalence 22 other ports mappedSource-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.
| Port | API | Differs from C# |
|---|---|---|
| C# | Lib Represents an immutable session handle and snapshot. | This page |
| Python | libtmux tmux(1) Session [session_manual]. | None recorded in the model |
| Ruby | Lib | None recorded in the model |
| Lua | libtmux | None recorded in the model |
| PowerShell | Lib Read sessions with optional exact selectors. | This cmdlet reads and returns shared .NET LibTmux.Session objects. Child windows and panes require further acquisition. |
| Julia | Lib | 2 overloads SessionSnapshot holds captured session data. Actions use its SessionRef, a typed identity bound to an observed daemon generation. |
| Erlang | #tmux | None recorded in the model |
| Elixir | Lib An immutable session observation. Attachment retains tmux's client count. | Session is an immutable observation. Fields not captured read as :unloaded. |
| Haskell | Lib 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: 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 One session on one tmux server, as a handle rather than a copy of it. | None recorded in the model |
| Rust | session One tmux session, together with the snapshot it was discovered with. | None recorded in the model |
| Go | tmux 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 One tmux session, as one capture saw it. | readonly |
| Clojure | libtmux 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 A tmux session and its captured windows and properties. | None recorded in the model |
| Scala | io 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# | Lib 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:: 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 | None recorded in the model |
| Perl | Lib Captured session entity | A captured read-only entity; explicit Server operations accept its stable identity. |
| Raku | Lib Captured session with local window-link and group relationships. | None recorded in the model |