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

Session.from_env

Find the session this process is running in.

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

Description#

Resolved through the pane, because TMUX_PANE names exactly one pane while a server's TMUX value names the session that was current when the client attached, which may since have changed.

Ok(None) means tmux no longer has that pane.

Errors

Returns an error when TMUX_PANE is absent or is not a pane ID, or when the listing fails.

Examples#

use libtmux::{Pane, Session};
let session = server.new_session("locating-session").await?;
let pane = session.panes().await?.remove(0);
// Standing in for the environment tmux gives a process it starts.
let found = Session::from_env_value(server, Some(pane.id().as_ref())).await?;
assert_eq!(found.expect("the session exists").id(), session.id());
Parameters

Guides#

Pages that discuss from_env.

In other ports#

The session this process is running inside

Equivalents of The session this process is running inside in other languages
Language Equivalent
Python libtmux.Session.from_env
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
TypeScript session.Session.fromEnv
Go no equivalent on Session
Java no equivalent on Session
C# LibTmux.Session.FromEnvironmentAsync
C++ no equivalent on Session
Swift no equivalent on Session
OCaml No direct public OCaml equivalent is recorded for this operation.
Perl No dedicated equivalent in the selected Perl surface. Explicit Server::cmd remains available for native tmux commands.

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

Esc

Type to search.

Reference previewOpen reference