# session.Session.fromEnv

- **Module:** session
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/073b9d7dedad900bff6f5ec0ea47794e40225870/packages/libtmux/src/session.ts#L452
- **Page:** https://libtmux.org/en/ts/latest/reference/session-session-fromenv/

```
static async fromEnv(
  environment: Readonly<
    Record<string, string | undefined>
  > = process.env,
): Promise<Session>
```

Resolve the session this process is running inside.

The pane is authoritative: `$TMUX`'s exported session id goes stale when a
pane is moved, so the session is looked up through `$TMUX_PANE` instead.

## Examples

```ts
const current = await Session.fromEnv();
current.name;
```

## Parameters

- `environment` (`Readonly<Record<string, string | undefined>>`)
  Default: `process.env`.

## Guides

Pages that discuss `fromEnv`.

- [Environment](/en/ts/latest/topics/environment/)

## In other ports

The session this process is running inside

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Session.from_env`](/en/py/latest/reference/libtmux-session-from_env/) (method) |
| Rust | [`session.Session.from_env`](/en/rs/latest/reference/session-session-from_env/) (method) |
| Go | no equivalent on `Session` |
| Java | no equivalent on `Session` |
| C# | [`LibTmux.Session.FromEnvironmentAsync`](/en/csharp/latest/reference/libtmux-session-fromenvironmentasync/) (method) |
| C++ | no equivalent on `Session` |
| Swift | no equivalent on `Session` |

No equivalent is recorded in Ruby, Lua, PowerShell, Julia, Elixir, Kotlin, Scala or F#.
