Add doc for aliases (#408)

This commit is contained in:
Denis Isidoro 2020-09-15 10:39:19 -03:00 committed by GitHub
parent fa08d58706
commit 5b9831e1a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View file

@ -50,6 +50,7 @@ There are multiple ways to use **navi**:
- pros: you have access to all possible subcommands and flags - pros: you have access to all possible subcommands and flags
- by invoking it via a [shell widget](docs/installation.md#installing-the-shell-widget) in the terminal - by invoking it via a [shell widget](docs/installation.md#installing-the-shell-widget) in the terminal
- pros: the shell history is correctly populated (i.e. with the actual command you ran instead of `navi`) and you can edit the command as you wish before executing it - pros: the shell history is correctly populated (i.e. with the actual command you ran instead of `navi`) and you can edit the command as you wish before executing it
- as [aliases](docs/aliases.md)
- as a [shell scripting tool](docs/shell_scripting.md) - as a [shell scripting tool](docs/shell_scripting.md)
- as an [Alfred workflow](docs/alfred.md) - as an [Alfred workflow](docs/alfred.md)

40
docs/aliases.md Normal file
View file

@ -0,0 +1,40 @@
Aliases
----------------------------
**navi** doesn't have support for aliases as first-class citizens at the moment.
However, it should be trivial to create aliases using **navi** + a few conventions.
For example, suppose you decide to end some of your commands with `:: <some_alias>`:
```bash
% aliases
# This is one command :: el
echo lorem ipsum
# This is another command :: ef
echo foo bar
```
Then, if you use **navi** as a [shell scripting tool](shell_scripting.md), you could add something similar to this in your `.bashrc`-like file:
```bash
navialias() {
navi --query ":: $1" --best-match
}
alias el="navialias el"
alias ef="navialias ef"
```
If you don't want to use these conventions, you can even add full comments in your aliases:
```bash
navibestmatch() {
navi --query ":: $1" --best-match
}
alias el="navibastmatch 'This is one command'"
alias ef="navibastmatch 'This is another command'"
```