# window.Window.from_env

- **Module:** window.Window
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/window.rs#L160
- **Page:** https://libtmux.org/reference/rs/window-window-from_env/

```
window.Window.from_env(server: &crate::Server) -> Result<Option<Self>, Error>
```

Find the window this process is running in.

Resolved through the pane named by `TMUX_PANE`, which is the only
value tmux gives a process that identifies exactly where it is.

`Ok(None)` means tmux no longer has that pane.

# Errors

Returns an error when `TMUX_PANE` is absent or is not a pane ID, or
when the listing fails.

## Example

```rust
use libtmux::Window;

let session = server.new_session("locating-window").await?;
let pane = session.panes().await?.remove(0);

// Standing in for the environment tmux gives a process it starts.
let found = Window::from_env_value(server, Some(pane.id().as_ref())).await?;

assert_eq!(found.expect("the window exists").id(), pane.window_id());
```
