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

Improve Documentation on how to persist aliases

Open thadguidry opened this issue 2 years ago • 7 comments

In the docs https://www.nushell.sh/book/aliases.html there is this statement:

For more details about how to persist aliases so that they're visible when you start up Nushell, see the configuration chapter.

However, if you click on that configuration chapter link and then search the page, you only see a small confusing snippet of a nuopen override example for MacOS, and nowhere else does it show how to persist aliases.

echo $nu.scope.aliases does work to show current aliases made in a session, but there should be a way to persist them much more easily somehow?

thadguidry avatar May 05 '23 07:05 thadguidry

It was suggested on Discord that:

Just type alias ll = ls -l into your config.nu, it should work.

But actually that does not. The config reports an error during nushell startup.

thadguidry avatar May 05 '23 07:05 thadguidry

I put this alias ll = ls -l at the top of my config and restarted nushell and ll works without issue. $nu.scope.aliases and help aliases both list the alias.

fdncred avatar May 05 '23 11:05 fdncred

Thanks, yes, I was able to finally get them to persist. Now we just need someone to work on this issue to improve the docs!

thadguidry avatar May 05 '23 11:05 thadguidry

It says, add them to the config file. What are you thinking about changing?

fdncred avatar May 05 '23 12:05 fdncred

lots of TYPES of things can be added into the config file. Variables, Commands (def's), etc. I honestly didn't know WHICH type or syntax to actually use to declare aliases because no simple example was shown or mentioned. The config file is technically TYPE aware, in that it is parsed for substructures. WHICH substructure to use to declare aliases is currently not clear without an example in the docs on that configuration page.

Also, it could further help to ship inside the default config.nu file at the top with a commented out

# The below syntax is how aliases can be declared.  Uncomment and add more.
# alias echohi = echo "hello world"

This would also make things much more understandable as well.

thadguidry avatar May 05 '23 12:05 thadguidry

I've said for a long time that the default_config.nu should have a bunch of comments to explain the syntax. So, I'd support such a change.

fdncred avatar May 06 '23 00:05 fdncred

Agree for the comment into the default_config.nu , and I shall say more : the doc may explain how to parse a file in a way to keep everything clean like https://discord.com/channels/601130461678272522/1103191812061011968/1103323548493303890 no ?

Denis4l avatar Jul 06 '23 08:07 Denis4l