mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 18:03:51 +01:00
Update alias docs to new syntax (#2917)
This confused me today after upgrading Nu. I believe this is now correct.
This commit is contained in:
parent
dff85a7f70
commit
dfb1e22559
@ -2,13 +2,12 @@
|
||||
|
||||
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> [<parameters>] {<body>}`
|
||||
Syntax: `alias {flags} <name> = <body>`
|
||||
|
||||
The command expects three parameters:
|
||||
The command expects two parameters:
|
||||
|
||||
* The name of the alias
|
||||
* The parameters as a space-separated list (`[a b ...]`), can be empty (`[]`)
|
||||
* The body of the alias as a `{...}` block
|
||||
* The body of the alias
|
||||
|
||||
## Flags
|
||||
|
||||
@ -19,31 +18,18 @@ The command expects three parameters:
|
||||
Define a custom `myecho` command as an alias:
|
||||
|
||||
```shell
|
||||
> alias myecho [msg] { echo $msg }
|
||||
> alias myecho = echo
|
||||
> myecho "hello world"
|
||||
hello world
|
||||
```
|
||||
|
||||
Since the parameters are well defined, calling the command with the wrong number of parameters will fail properly:
|
||||
|
||||
```shell
|
||||
> myecho hello world
|
||||
error: myecho unexpected world
|
||||
- shell:1:18
|
||||
1 | myecho hello world
|
||||
| ^^^^^ unexpected argument (try myecho -h)
|
||||
```
|
||||
|
||||
The suggested help command works!
|
||||
|
||||
```shell
|
||||
> myecho -h
|
||||
|
||||
Usage:
|
||||
> myecho ($msg) {flags}
|
||||
|
||||
parameters:
|
||||
($msg)
|
||||
> myecho {flags}
|
||||
|
||||
flags:
|
||||
-h, --help: Display this help message
|
||||
@ -54,7 +40,7 @@ flags:
|
||||
Aliases are most useful when they are persistent. For that, use the `--save` flag:
|
||||
|
||||
```shell
|
||||
> alias --save myecho [msg] { echo $msg }
|
||||
> 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`.
|
||||
|
Loading…
Reference in New Issue
Block a user