Skip to content

Commit 6b96dd4

Browse files
authored
Improve cookbook setup env setup (#1972)
Resolves #1926
1 parent b1f2f58 commit 6b96dd4

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

cookbook/setup.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,35 @@ There are other ways to view these values and variables, however setting up your
1111

1212
### Configure your path and other environment variables
1313

14-
In order to configure your path in nushell you'll need to modify your `PATH` environment variable in your `config.nu` file. Open your `config.nu` file and put an entry in it like `$env.PATH = "path1;path2;path3"` ensuring that you use the proper path separation character, which is different by platform.
14+
In your `env.nu`, you can set up your environment.
1515

16-
Alternately, if you want to append a folder to your `PATH` environment variable you can do that too using the `append` or `prepend` command like this:
16+
To configure environment variables, you use the `$env` variable:
1717

1818
```nu
19-
$env.PATH = ($env.PATH | split row (char esep) | append "some/other/path")
19+
$env.TITLE = 'Nu Test'
20+
$env.VALUE = 123
2021
```
2122

22-
For more detailed instructions, see the documentation about [environment variables](/book/environment.html#setting-environment-variables) and [PATH configuration](/book/configuration.html#path-configuration).
23+
To add paths to the `PATH` environment variable, you can append them:
24+
25+
```nu
26+
$env.PATH ++= ['~/.local/bin']
27+
```
28+
29+
Because you can append a list of paths, you can append multiple at once. You can also use subcommands to construct the paths in line.
30+
31+
```nu
32+
$env.PATH ++= [ '~/.local/bin', ($env.CARGO_HOME | path join "bin") ]
33+
```
34+
35+
Because PATH order makes a difference, you may want to *prepend* your paths instead, so that they take precedence over other executables with the same name:
36+
37+
```
38+
use std/util "path add"
39+
path add '~/.local/bin'
40+
```
41+
42+
For more information, see the documentation about [environment variables](/book/environment.html#setting-environment-variables) and [PATH configuration](/book/configuration.html#path-configuration).
2343

2444
### How to list your environment variables
2545

0 commit comments

Comments
 (0)