Session
One session on one tmux server, as a handle rather than a copy of it.
Source and package
-
Description#
Reached from
Server.sessions()or by creating one; the constructor throws. The tmux format row the handle was built from reads back throughformat, and by tmux's own field names directly on the handle — a snapshot taken when the handle was made, not a live view.A session outlives the clients attached to it: killing the last client leaves the session running, which is the property the whole tool is built around.
What is on here. A session handle reads and changes the one session it addresses. Its members fall into a few groups:
- Which session this is
- Each tmux field of the session reads directly on the handle, such as
idandname, as it was when the handle was made, andformataddresses the same row by tmux's own token names, which covers a field tmux added in a later version. Reading the session again returns a new handle and leaves the receiver at the instant it was read. One comparison needs the same socket, daemon, and$n; the other asks only for the same$n, which sessions on unrelated servers routinely share. - IdentityCompareReach
- Windows and panes
- A session's windows and panes come from the graph the handle was materialized against, so reading them issues no tmux command and reports the instant the handle came from. The active pane takes two hops rather than one, because
pane_activeis per window: every window has an active pane, and only the active window's is the session's. - Active
- Changing things
- Creating a window costs a snapshot of the whole server, not of this session: a window made here is linked into every session grouped with it, and the handle reports those links.
indexselects an exact slot, and an occupied slot fails without replacing its window. A rename refuses a name the supported servers would not store identically, andplan()describes the same mutations forServer.batch()to run together. - WindowsPlanned
- Options, hooks, and environment
showOptions()reports only what is set on this session, which for a fresh one is often nothing, whereshowResolvedOptions()adds what it inherits. A hook reads back under the namesetHook()takes, and withoutappendsetting one replaces whatever it ran.getEnvironment()answersundefinedwhen tmux carries no entry, and whereunsetEnvironment()drops an entry,removeEnvironment()keeps it and marks it for removal from the processes tmux starts.- Clients and raw commands
- Detaching detaches every client attached to this session, which keeps running. A command this package does not model goes through
cmd(): its first argument is the command name and nothing else, the arguments go in the array, and the session's id is sent as the target unlesstargetsays otherwise.
Members32#
Parent objects1#
Collections and queries2#
Common operations25#
- newWindow method Create a window in this session and resolve it as a handle.
- kill method Destroy this session.
- rename method Rename this session.
- showHooks method Every hook this session reports.
- showOptions method Every option set on this session itself, not the ones it inherits.
- setOption method Set an option on this session.
- unsetOption method Remove an option from this session.
- setHook method Bind a tmux command to a hook on this session.
- showEnvironment method Every variable in this session's environment.
- setEnvironment method Set a variable in this session's environment.
- unsetEnvironment method Drop a variable from this session's environment entirely.
- detach method Detach every client attached to this session.
- activeWindow method The window tmux marks active in this session.
- unsetHook method Remove a hook from this session.
- activePane method The pane tmux marks active in this session's active window.
- refreshed method This session, read again at a new instant.
- removeEnvironment method Mark a variable in this session's environment for removal from the environment of processes tmux starts, leaving the entry in place.
- selectWindow method Select the last, next, or previous window, or one named by target.
- cmd method Run a tmux command this package does not model, addressed at this session.
- fromEnv method Resolve the session this process is running inside.
- getEnvironment method One variable from this session's environment, or
undefinedwhen tmux carries no entry. - equals method Whether
otheris this same session on this same server. - plan method The same mutations, described instead of run.
- sameTmuxIdAs method Whether
othercarries the same$n, wherever it came from. - showResolvedOptions method The option values that govern this session, own and inherited together.
Other members4#
- constructor method
- format: Session
Row property The raw tmux format row, addressed by tmux's own token names. - sessionBrand: undefined attribute
- toString method How this handle renders in a log line, a template literal, or an error.
Guides#
Pages that discuss Session.
- Concepts
- Topics
In other ports#
A tmux session
| Language | Equivalent |
|---|---|
| Python | libtmux |
| Ruby | Lib |
| Lua | libtmux |
| PowerShell | Lib This cmdlet reads and returns shared .NET LibTmux.Session objects. Child windows and panes require further acquisition. |
| Julia | Lib SessionSnapshot holds captured session data. Actions use its SessionRef, a typed identity bound to an observed daemon generation. |
| Erlang | #tmux |
| Elixir | Lib Session is an immutable observation. Fields not captured read as :unloaded. |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| Common Lisp | libtmux: session is an immutable captured entity. The same name also has a relation accessor with a distinct public identity. |
| Rust | session |
| Go | tmux |
| Java | io |
| Clojure | libtmux Acquires a vector of captured session maps. The session value is a map, not a wrapper class. |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| F# | Lib 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:: |
| Swift | Session |
| OCaml | Libtmux |
| Perl | Lib A captured read-only entity; explicit Server operations accept its stable identity. |