Skip to content

Order $env variables in Special Variables #1977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions book/special_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,32 @@ The `$nu` constant is a record containing several useful values:

There are also several environment variables that Nushell uses for specific purposes:

### `$env.CMD_DURATION_MS`

The amount of time in milliseconds that the previous command took to run.

### `$env.config`

`$env.config` is the main configuration record used in Nushell. Settings are documented in `config nu --doc`.

### `$env.PATH`

The search path for executing other applications. It is initially inherited from the parent process as a string, but converted to a Nushell `list` at startup for easy access.
### `$env.CURRENT_FILE`

It is converted back to a string before running a child-process.
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.ENV_CONVERSIONS`

Allows users to specify how to convert certain environment variables to Nushell types. See [ENV_CONVERSIONS](./configuration.md#env-conversions).

### `$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.LAST_EXIT_CODE`

The exit code of the last command, usually used for external commands — Equivalent to `$?` from POSIX. Note that this information is also made available to the `catch` block in a `try` expression for external commands. For instance:
Expand All @@ -81,27 +93,29 @@ try {
# => 2
```

### `$env.CMD_DURATION_MS`
### `$env.NU_LIB_DIRS`

The amount of time in milliseconds that the previous command took to run.
A list of directories which will be searched when using the `source`, `use`, or `overlay use` commands. See also:

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

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.NU_PLUGIN_DIRS`

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

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.
- [Plugin Search Path](./plugins.md#plugin-search-path)

### `$env.FILE_PWD`
### `$env.NU_VERSION`

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:
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.

```nu
path self | path dirname
```
### `$env.PATH`

The search path for executing other applications. It is initially inherited from the parent process as a string, but converted to a Nushell `list` at startup for easy access.

It is converted back to a string before running a child-process.

### `$env.PROCESS_PATH`

Expand All @@ -110,20 +124,6 @@ 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:
Expand Down