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.environment

Read one variable from the session's environment.

Source and package
Qualified name
libtmux::session::Session::environment
Module
session
Declared in
Session
Package
libtmux
Source
crates/libtmux/src/session/settings.rs
Other languages
Perlmethod Erlang PowerShell Julia Elixir Haskell Common Lisp PythonRubyLuaTypeScriptGo Java C# C++ Swift Kotlin Scala OCamlfunction F# Clojure
pub async fn environment(&self, name: &str) -> Result< Option<EnvironmentEntry>, Error >

Description#

tmux keeps two different things under a name: a value, and a mark saying a process started here must not inherit the name at all. EnvironmentEntry keeps them apart, because collapsing both to absence would hide the second, which a caller sets deliberately with Self::hide_environment().

None means tmux holds nothing under the name.

Errors

Returns an error when tmux cannot be reached.

Examples#

use libtmux::EnvironmentEntry;
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("read").await?;
assert_eq!(session.environment("EDITOR").await?, None);
session.set_environment("EDITOR", "hx").await?;
assert!(matches!(
session.environment("EDITOR").await?,
Some(EnvironmentEntry::Set(value)) if value.as_bytes() == b"hx",
));
session.hide_environment("EDITOR").await?;
assert_eq!(
session.environment("EDITOR").await?,
Some(EnvironmentEntry::Removed),
);
guard.shutdown().await?;
Parameters

In other ports#

Read a session's environment

Equivalents of Read a session's environment in other languages
Language Equivalent
Python libtmux.Session.show_environment
Ruby LibTmux::Session#environment
Lua libtmux.Session:list_environment
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
TypeScript session.Session.showEnvironment
Go tmux.Session.ShowEnvironment
Java no equivalent on Session
C# LibTmux.Session.Environment
C++ no equivalent on Session
Swift Server.environment(_:)
OCaml Libtmux_unix.Client.capture_environment Pass Environment.Global for server values or Environment.Session with a bound session target. Acquisition is explicit.
Perl No dedicated equivalent in the selected Perl surface. Explicit Server::cmd remains available for native tmux commands.

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

Read one variable from a session's environment

Equivalents of Read one variable from a session's environment in other languages
Language Equivalent
Python no single-variable read; the whole table is returned
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
TypeScript session.Session.getEnvironment
Go tmux.Session.GetEnvironment
Java no single-variable read; the whole table is returned
C# no single-variable read; the whole table is returned
C++ no single-variable read; the whole table is returned
Swift no single-variable read; the whole table is returned
OCaml No direct public OCaml equivalent is recorded for this operation.
Perl LibTmux::Server::get_environment Pass an explicit session ID. Empty text and zero-like text remain values.

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