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.

method libtmux-rs latest

Server.session

Find the session with this exact name.

Source and package
Qualified name
libtmux::server::Server::session
Module
server
Declared in
Server
Package
libtmux
Source
crates/libtmux/src/server/discovery.rs
Other languages
Perlmethod Erlang PowerShell Julia Elixir Haskell Common Lisp Python Ruby Lua TypeScript Go Java C#C++ Swift Kotlin Scala OCamlfunction F# Clojure
pub async fn session( &self, name: impl AsRef<[u8]> ) -> Result<Option<Session>, Error>

Description#

Names are compared as bytes, because tmux permits names that are not valid UTF-8.

The comparison happens here rather than through tmux's -f, which would filter server-side but requires building a format string around the name. A name containing #, }, or a comma would change the predicate's meaning, and tmux documents no escaping for those values, so a lookup would be an injection point.

This also finds a session whose name holds : or ., which -t name and -t =name both misread as a window or pane separator on every tmux release, = included: tmux splits a target on :/. before it looks for =. docs/findings.md has the detail, including the name: spelling that tmux 3.7a and later do accept for such a name. Prefer Session::id() over the name for any target built after this call; an ID target parses with no split at all.

Errors

Returns an error when the session listing fails.

Parameters

In other ports#

Look one session up by target

Equivalents of Look one session up by target in other languages
Language Equivalent
Python no equivalent on Server
Ruby LibTmux::Server#session
Erlang tmux_session:get/2
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
TypeScript no equivalent on Server
Go tmux.Server.Session
Java no equivalent on Server
C# LibTmux.Server.GetSessionAsync
C++ libtmux::Server::session
Swift no equivalent on Server
OCaml Libtmux.Snapshot.find_session Exact opaque-ID lookup in an existing snapshot, without I/O or tmux target expansion.
Perl LibTmux::Snapshot::session_by_id Captured stable-ID lookup returns an entity or undef. Use Selection::one for strict criteria/name lookup.

No equivalent is recorded in Lua, PowerShell, Julia, Elixir, Common Lisp, Clojure, Kotlin, Scala or F#.

Esc

Type to search.

Reference previewOpen reference