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.

class libtmux-ts latest

Session

One session on one tmux server, as a handle rather than a copy of it.

Source and package
Qualified name
Session
Module
session
Package
libtmux
Source
packages/libtmux/src/session.ts
Other languages
Perlclass ErlangPowerShellcmdlet Juliastruct Elixirstruct Haskell Common Lispclass PythonRubyLuaRustGoJavaC#C++SwiftKotlinScalaOCamlF#module Clojurefunction
class session.Session

Description#

Reached from Server.sessions() or by creating one; the constructor throws. The tmux format row the handle was built from reads back through format, 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 id and name, as it was when the handle was made, and format addresses 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.
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_active is per window: every window has an active pane, and only the active window's is the session's.
Held by the handle
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. index selects an exact slot, and an occupied slot fails without replacing its window. A rename refuses a name the supported servers would not store identically, and plan() describes the same mutations for Server.batch() to run together.
The session
Planned
Options, hooks, and environment
showOptions() reports only what is set on this session, which for a fresh one is often nothing, where showResolvedOptions() adds what it inherits. A hook reads back under the name setHook() takes, and without append setting one replaces whatever it ran. getEnvironment() answers undefined when tmux carries no entry, and where unsetEnvironment() 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 unless target says otherwise.

Members32#

Parent objects1#

  • server: Server attribute The server this handle addresses.

Collections and queries2#

  • windows method Windows placed in this session, in listing order.
  • panes method Panes contained by this session's windows.

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 undefined when tmux carries no entry.
  • equals method Whether other is this same session on this same server.
  • plan method The same mutations, described instead of run.
  • sameTmuxIdAs method Whether other carries the same $n, wherever it came from.
  • showResolvedOptions method The option values that govern this session, own and inherited together.

Other members4#

Guides#

Pages that discuss Session.

Topics

In other ports#

A tmux session

Equivalents of A tmux session in other languages
Language Equivalent
Python libtmux.Session
Ruby LibTmux::Session
Lua libtmux.Session
PowerShell LibTmux\Get-TmuxSession This cmdlet reads and returns shared .NET LibTmux.Session objects. Child windows and panes require further acquisition.
Julia LibTmux.SessionSnapshot SessionSnapshot holds captured session data. Actions use its SessionRef, a typed identity bound to an observed daemon generation.
Erlang #tmux_model:session{}
Elixir LibTmux.Session 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 session is an immutable captured entity. The same name also has a relation accessor with a distinct public identity.
Rust session.Session
Go tmux.Session
Java io.github.libtmux.Session
Clojure libtmux.core/sessions! Acquires a vector of captured session maps. The session value is a map, not a wrapper class.
Kotlin io.github.libtmux.kotlin.Session
Scala io.github.libtmux.scaladsl.Session
C# LibTmux.Session
F# LibTmux.FSharp.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
Swift Session
OCaml Libtmux.Session.t
Perl LibTmux::Session A captured read-only entity; explicit Server operations accept its stable identity.
Esc

Type to search.

Reference previewOpen reference