nushell.github.io
nushell.github.io copied to clipboard
Document the pathvar command
Some of the info in Coming from bash
page and the Adding paths to your PATH
page needs to be updated to include pathvar
.
#188 adds an example for pathvar add
in the table, but perhaps we should add a Path
section to the Environment page in the book? I'm currently documenting nushell/nushell#3950 on that page and I would gladly add information about working with the path env var as well.
In general, we could use some more information about manipulating the PATH in Nu.
We currently have pathvar
, which makes it very easy to add and remove specific paths. However, it is also possible to change the path by setting a value to the PATH
env var (or Path
on Windows). I don't know if this is intended or not?
> pathvar add ~/.local/bin
# works!
> let-env PATH = (pathvar | prepend ("~/.local/bin" | path expand) | str collect ":")
# also works!
Both of the above do the same thing. The second one is closer to what we usually see in other shells (and can be done with string concatenation to make it resemble that pattern even more).
Setting the PATH all at once as a string has its use cases, like restoring an old PATH when you don't know the number of elements you would like to remove. This happens when you're working with some virtual environments that add more than one path element.
I would like to document this, if it's intended to work like this.
I think this can be closed - While the original pathvar
is obsolete, the "Coming from Bash" chapter now includes:
$env.PATH = ($env.PATH | append /usr/other/bin)
And there's a more in-depth discussion in the Configuration chapter.