# session.Session.environment_all

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

```
session.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. The listing is read in tmux's shell form,
which escapes each value, so a value containing a newline or an `=`
is not mistaken for the next variable. Each value reads exactly as
[`Self::environment`] reads it. Names are not escaped: a removed name
holding `;` and a newline lists exactly as two removed names do, and
reads as them.

# Errors

Returns an error when tmux cannot be reached or refuses the listing,
and [`Error::DecodeListing`] when the listing is not in the shape tmux
prints. 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?;
```
