# server.Server.getEnvironment

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

```
getEnvironment(
  name: string,
): Promise<EnvironmentValue | undefined>
```

One variable from the server's global environment, or [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) when tmux carries no entry.

## Examples

```ts
await server.getEnvironment("EDITOR"); // "vim", null, or undefined
```

## Parameters

- `name` (`string`)

## tmux command

The tmux commands behind `getEnvironment`.

- [`show-environment`](/en/tmux/latest/manual/show-environment/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_show_environment_entry`](/en/tmux/latest/reference/c-variable-cmd_show_environment_entry/) (attribute)
- [`cmd_show_environment_exec`](/en/tmux/latest/reference/c-function-cmd-show-environment-c-cmd_show_environment_exec/) (function)

## In other ports

Read one variable from the server's environment

| Language | Equivalent |
| --- | --- |
| Python | no single-variable read; the whole table is returned |
| Rust | [`server.Server.environment`](/en/rs/latest/reference/server-server-environment/) (method) |
| Go | [`tmux.Server.GetEnvironment`](/en/go/latest/reference/tmux-server-getenvironment/) (method) |
| Java | no single-variable read; the whole table is returned |
| C# | 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 |

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