2020-05-03 04:49:27 +00:00
# alias
2020-06-23 18:21:47 +00:00
2020-05-24 17:42:20 +00:00
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` .
2021-01-12 19:30:27 +00:00
Syntax: `alias {flags} <name> = <body>`
2020-05-03 04:49:27 +00:00
2021-01-12 19:30:27 +00:00
The command expects two parameters:
2020-06-23 18:21:47 +00:00
2020-08-01 12:11:26 +00:00
* The name of the alias
2021-01-12 19:30:27 +00:00
* The body of the alias
2020-05-03 04:49:27 +00:00
2020-05-24 17:42:20 +00:00
## Flags
2020-07-22 21:42:04 +00:00
* `-s` , `--save` : Save the alias to your config (see `config path` to edit them later)
2020-05-24 17:42:20 +00:00
2020-05-03 04:49:27 +00:00
## Examples
Define a custom `myecho` command as an alias:
2020-06-23 18:21:47 +00:00
2020-05-03 04:49:27 +00:00
```shell
2021-01-12 19:30:27 +00:00
> alias myecho = echo
2020-05-03 04:49:27 +00:00
> myecho "hello world"
hello world
```
The suggested help command works!
2020-06-23 18:21:47 +00:00
2020-05-03 04:49:27 +00:00
```shell
> myecho -h
Usage:
2021-01-12 19:30:27 +00:00
> myecho {flags}
2020-05-03 04:49:27 +00:00
flags:
-h, --help: Display this help message
```
## Persistent aliases
2020-08-01 12:11:26 +00:00
Aliases are most useful when they are persistent. For that, use the `--save` flag:
2020-06-23 18:21:47 +00:00
```shell
2021-01-12 19:30:27 +00:00
> alias --save myecho = echo
2020-05-03 04:49:27 +00:00
```
2020-06-23 18:21:47 +00:00
2020-08-01 12:11:26 +00:00
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` .
2020-06-23 18:21:47 +00:00
2020-08-01 12:11:26 +00:00
For example, to edit your config file in `vi` , run:
2020-06-23 18:21:47 +00:00
```shell
2020-08-01 12:11:26 +00:00
> vi $(config path)
2020-05-03 04:49:27 +00:00
```