# session.settings.Session.environment_all

- **Module:** session.settings.Session
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/session/settings.rs#L423
- **Page:** https://libtmux.org/reference/rs/session-settings-session-environment_all/

```
session.settings.Session.environment_all(self) -> Result<BTreeMap<String, EnvironmentEntry>, Error>
```

Read the session's whole environment.

tmux distinguishes a variable it holds a value for from one it has
marked for *removal*, so that a process started in the session does not
inherit it. Both appear in the listing, and [`EnvironmentEntry`] keeps
them apart, exactly as [`Self::environment`] does for a single name.

Costs one tmux command per variable. The listing alone cannot be
trusted: a value containing a newline occupies more than one line, and
a continuation line holding an `=` is indistinguishable from the next
variable. Each name is therefore read back on its own, which also
discards the continuation lines, because tmux refuses a name it does
not hold.

# Errors

Returns an error when tmux cannot be reached or refuses the listing.
An empty map means the session holds nothing, never that the listing
failed.

## Example

```rust
use libtmux::EnvironmentEntry;

let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("env").await?;

session.set_environment("EDITOR", "vi").await?;
session.hide_environment("PAGER").await?;

let environment = session.environment_all().await?;
assert!(matches!(
    environment.get("EDITOR"),
    Some(EnvironmentEntry::Set(value)) if value.as_bytes() == b"vi",
));
assert_eq!(environment.get("PAGER"), Some(&EnvironmentEntry::Removed));

guard.shutdown().await?;
```
