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
-
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.
EnvironmentEntrykeeps them apart, because collapsing both to absence would hide the second, which a caller sets deliberately withSelf::hide_environment().Nonemeans 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?;
In other ports#
Read a session's environment
| Language | Equivalent |
|---|---|
| Python | libtmux |
| Ruby | Lib |
| Lua | libtmux |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | session |
| Go | tmux |
| Java | no equivalent on Session |
| C# | Lib |
| C++ | no equivalent on Session |
| Swift | Server |
| OCaml | Libtmux 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
| 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 |
| Go | tmux |
| 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 | Lib 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#.