Skip to content

Commit b758fb7

Browse files
authored
Order $env variables in Special Variables (#1977)
The order C P E L C N C F P N N P S X X was quite confusing. While there is value in putting the config and PATH first, because they are common and important variables, the table of contents becomes very inconsistent and confusing when mixed like before.
1 parent b1de452 commit b758fb7

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

book/special_variables.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,32 @@ The `$nu` constant is a record containing several useful values:
4949

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

52+
### `$env.CMD_DURATION_MS`
53+
54+
The amount of time in milliseconds that the previous command took to run.
55+
5256
### `$env.config`
5357

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

56-
### `$env.PATH`
57-
58-
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.
60+
### `$env.CURRENT_FILE`
5961

60-
It is converted back to a string before running a child-process.
62+
Inside a script, module, or sourced-file, this variable holds the fully-qualified filename. Note that this
63+
information is also available as a constant through the [`path self`](/commands/docs/path_self.md) command.
6164

6265
### `$env.ENV_CONVERSIONS`
6366

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

69+
### `$env.FILE_PWD`
70+
71+
Inside a script, module, or sourced-file, this variable holds the fully qualified name of the directory in which
72+
the file resides. Note that this value is also available as a constant through:
73+
74+
```nu
75+
path self | path dirname
76+
```
77+
6678
### `$env.LAST_EXIT_CODE`
6779

6880
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:
@@ -81,27 +93,29 @@ try {
8193
# => 2
8294
```
8395

84-
### `$env.CMD_DURATION_MS`
96+
### `$env.NU_LIB_DIRS`
8597

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

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

90-
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.
104+
### `$env.NU_PLUGIN_DIRS`
91105

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

94-
Inside a script, module, or sourced-file, this variable holds the fully-qualified filename. Note that this
95-
information is also available as a constant through the [`path self`](/commands/docs/path_self.md) command.
108+
- [Plugin Search Path](./plugins.md#plugin-search-path)
96109

97-
### `$env.FILE_PWD`
110+
### `$env.NU_VERSION`
98111

99-
Inside a script, module, or sourced-file, this variable holds the fully qualified name of the directory in which
100-
the file resides. Note that this value is also available as a constant through:
112+
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.
101113

102-
```nu
103-
path self | path dirname
104-
```
114+
### `$env.PATH`
115+
116+
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.
117+
118+
It is converted back to a string before running a child-process.
105119

106120
### `$env.PROCESS_PATH`
107121

@@ -110,20 +124,6 @@ above, it is not present when sourcing a file or importing a module.
110124

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

113-
### `$env.NU_LIB_DIRS`
114-
115-
A list of directories which will be searched when using the `source`, `use`, or `overlay use` commands. See also:
116-
117-
- The `$NU_LIB_DIRS` constant below
118-
- [Module Path](./modules/using_modules.md#module-path)
119-
- [Configuration - `$NU_LIB_DIRS`](./configuration.md#nu-lib-dirs-constant)
120-
121-
### `$env.NU_PLUGIN_DIRS`
122-
123-
A list of directories which will be searched when registering plugins with `plugin add`. See also:
124-
125-
- [Plugin Search Path](./plugins.md#plugin-search-path)
126-
127127
### `$env.PROMPT_*` and `$env.TRANSIENT_PROMPT_*`
128128

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

0 commit comments

Comments
 (0)