nushell.github.io icon indicating copy to clipboard operation
nushell.github.io copied to clipboard

Document the pathvar command

Open nathom opened this issue 3 years ago • 2 comments

Some of the info in Coming from bash page and the Adding paths to your PATH page needs to be updated to include pathvar.

nathom avatar Jul 23 '21 21:07 nathom

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

filaretov avatar Aug 26 '21 19:08 filaretov

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.

filaretov avatar Aug 26 '21 19:08 filaretov

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.

NotTheDr01ds avatar Aug 07 '24 19:08 NotTheDr01ds