1
0
mirror of https://github.com/nushell/nushell.git synced 2025-04-17 09:48:19 +02:00
nushell/docs/commands/alias.md
Louis Pilfold dfb1e22559
Update alias docs to new syntax ()
This confused me today after upgrading Nu. I believe this is now correct.
2021-01-13 08:30:27 +13:00

1.1 KiB

alias

This command allows you to define shortcuts for other common commands. By default, they only apply to the current session. To persist them, add --save.

Syntax: alias {flags} <name> = <body>

The command expects two parameters:

  • The name of the alias
  • The body of the alias

Flags

  • -s, --save: Save the alias to your config (see config path to edit them later)

Examples

Define a custom myecho command as an alias:

> alias myecho = echo
> myecho "hello world"
hello world

The suggested help command works!

> myecho -h

Usage:
  > myecho {flags}

flags:
  -h, --help: Display this help message

Persistent aliases

Aliases are most useful when they are persistent. For that, use the --save flag:

> alias --save myecho = echo

This will store the alias in your config, under the startup key. To edit the saved alias, run it again with the same name, or edit your config file directly. You can find the location of the file using config path.

For example, to edit your config file in vi, run:

> vi $(config path)