session.Session.environment
- Module
- session
- Declared in
- Session
- Package
- libtmux
- Source
- crates/libtmux/src/session/settings.rs
- Other languages
- PythonRubyLuaTypeScriptGo Java .NET C++ Swift
-
Read one variable from the session's environment.
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.
In other ports Read a session's environment
- Python
libtmux.Session.show_environment - Ruby
LibTmux::Session#environment - Lua
libtmux.Session:list_environment - TypeScript
session.Session.showEnvironment - Go
tmux.Session.ShowEnvironment - Java no equivalent on
Session - .NET
LibTmux.Session.Environment - C++ no equivalent on
Session - Swift
Server.environment(_:)
In other ports Read one variable from a session's environment
- Python no single-variable read; the whole table is returned
- Ruby No source-verified Ruby equivalent is recorded for this operation.
- Lua No source-verified Lua equivalent is recorded for this operation.
- TypeScript
session.Session.getEnvironment - Go
tmux.Session.GetEnvironment - Java no single-variable read; the whole table is returned
- .NET 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
- Python
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?;const environment = await session.showEnvironment();environment.get("EDITOR");0 declared, 0 inherited