Home Explore Blog CI



nushell

3rd chunk of `book/special_variables.md`
08fc4080c8545f12cafd872b3dd7a989fcf061a66267e1cf0000000100000cc0
### `$env.NU_VERSION`

The current Nushell version. The same as `(version).version`, but, as an environment variable, it is exported to and can be read by child processes.

### `$env.CURRENT_FILE`

Inside a script, module, or sourced-file, this variable holds the fully-qualified filename. Note that this
information is also available as a constant through the [`path self`](/commands/docs/path_self.md) command.

### `$env.FILE_PWD`

Inside a script, module, or sourced-file, this variable holds the fully qualified name of the directory in which
the file resides. Note that this value is also available as a constant through:

```nu
path self | path dirname
```

### `$env.PROCESS_PATH`

When _executing a script_, this variable represents the name and relative path of the script. Unlike the two variables
above, it is not present when sourcing a file or importing a module.

Note: Also unlike the two variables above, the exact path (including symlinks) that was used to _invoke_ the file is returned.

### `$env.NU_LIB_DIRS`

A list of directories which will be searched when using the `source`, `use`, or `overlay use` commands. See also:

- The `$NU_LIB_DIRS` constant below
- [Module Path](./modules/using_modules.md#module-path)
- [Configuration - `$NU_LIB_DIRS`](./configuration.md#nu-lib-dirs-constant)

### `$env.NU_PLUGIN_DIRS`

A list of directories which will be searched when registering plugins with `plugin add`. See also:

- [Plugin Search Path](./plugins.md#plugin-search-path)

### `$env.PROMPT_*` and `$env.TRANSIENT_PROMPT_*`

A number of variables are available for configuring the Nushell prompt that appears on each commandline. See also:

- [Configuration - Prompt Configuration](./configuration.md#prompt-configuration)
- `config nu --doc`

### `$env.SHLVL`

`SHLVL` is incremented by most shells when entering a new subshell. It can be used to determine the number of nested shells. For instance,
if `$env.SHLVL == 2` then typing `exit` should return you to a parent shell.

### `$env.XDG_CONFIG_HOME`

Can be used to optionally override the `$nu.default-config-dir` location. See [Configuration - Startup Variables](./configuration.md#startup-variables).

### `$env.XDG_DATA_DIR`

Can be used to optionally override the `$nu.data-dir` location. See [Configuration - Startup Variables](./configuration.md#startup-variables).

## `$in`

The `$in` variable represents the pipeline input into an expression. See [Pipelines - The Special `$in` Variable](./pipelines.md#pipeline-input-and-the-special-in-variable).

## `$it`

`$it` is a special variable that is _only_ available in a `where` "row condition" — a convenient shorthand which simplifies field access. See `help where` for more information.

## `$NU_LIB_DIRS`

A constant version of `$env.NU_LIB_DIRS` - a list of directories which will be searched when using the `source`, `use`, or `overlay use` commands. See also:

- [Module Path](./modules/using_modules.md#module-path)
- [Configuration - `$NU_LIB_DIRS`](./configuration.md#nu-lib-dirs-constant)

## `$NU_PLUGIN_DIRS`

A constant version of `$env.NU_PLUGIN_DIRS` - a list of directories which will be searched when registering plugins with `plugin add`. See also:

- [Plugin Search Path](./plugins.md#plugin-search-path)

Title: More Nushell Variables: `$env`, `$in`, `$it`, `$NU_LIB_DIRS`, `$NU_PLUGIN_DIRS`
Summary
This section details additional Nushell variables. It covers `$env.NU_VERSION` (Nushell version), `$env.CURRENT_FILE` (script/module filename), `$env.FILE_PWD` (script/module directory), `$env.PROCESS_PATH` (script path when executed), `$env.NU_LIB_DIRS` (directories for `source`, `use`, `overlay use`), `$env.NU_PLUGIN_DIRS` (directories for `plugin add`), `$env.PROMPT_*` and `$env.TRANSIENT_PROMPT_*` (prompt configuration), `$env.SHLVL` (shell nesting level), `$env.XDG_CONFIG_HOME` and `$env.XDG_DATA_DIR` (overriding default config/data directories). It also describes `$in` (pipeline input), `$it` (shorthand in `where` conditions), `$NU_LIB_DIRS` (constant version of `$env.NU_LIB_DIRS`), and `$NU_PLUGIN_DIRS` (constant version of `$env.NU_PLUGIN_DIRS`).