:information_source: If you're here because you upgraded navi and are having some issues, please check this thread.
An interactive cheatsheet tool for the command-line.
navi allows you to browse through cheatsheets (that you may write yourself or download from maintainers) and execute commands. Argument suggestions are prompted to you.
It uses fzf under the hood and it can be either used as a command or as a shell widget (à la Ctrl-R).
sh
brew install denisidoro/tools/navi
Alternatively, you can use the official formula (but it will install a very old version):
sh
brew install navi
bash
cargo install navi
```bash bash <(curl -sL https://raw.githubusercontent.com/denisidoro/navi/master/scripts/install)
```
You can download binaries here.
```bash git clone https://github.com/denisidoro/navi ~/.navi cd ~/.navi make install
```
By running navi
for the first time, you'll be suggested to download some cheatsheets. By running navi
again, these cheatsheets will appear.
You can use navi as a widget to your shell. This way, your history is correctly populated and you can edit the command as you wish before executing it. To set it up, add this line to your .bashrc
-like file:
```sh
source <(navi widget bash)
source <(navi widget zsh)
navi widget fish | source ```
By default, Ctrl+G
is assigned to launching navi.
Please refer to navi --help
for more details.
If you don't have access to a Unix shell at the moment and you want to live preview navi, head to this playground. It'll start a docker container with instructions for you to install and use the tool. Note: login required.
navi is able to import cheatsheets from git repositories:
navi repo add https://github.com/denisidoro/navi
You can either start a git repo with cheatsheets and import it as described above or you can add them directly to data_dir/navi
.
The main repository for cheatsheets is denisidoro/cheats. Feel free to open a PR there for me to include your contributions.
Cheatsheets are described in .cheat
files that look like this:
```sh % git, code
git checkout
$ branch: git branch | awk '{print $NF}' ```
%
determine the start of a new cheatsheet and should contain tags, useful for searching;#
should be descriptions of commands;;
are ignored. You can use them for metacomments;$
should contain commands that generate a list of possible values for a given argument;It's irrelevant how many files are used to store cheatsheets. They can be all in a single file if you wish, as long as you split them accordingly with lines starting with %
.
The interface prompts for variable names inside brackets (eg <branch>
).
Variable names should only include alphanumeric characters and _
.
If there's a corresponding line starting with $
for a variable, suggestions will be displayed. Otherwise, the user will be able to type any value for it.
For lines starting with $
you can add use ---
to customize the behavior of fzf
or how the value is going to be used:
```sh
docker rmi
$ image_id: docker images --- --column 3 --header-lines 1 --delimiter '\s\s+' ```
The supported parameters are:
- --allow-extra
(experimental): handles fzf
option --print-query
. enter
will prefer a selection and tab
will prefer the query typed.
- --multi
: forwarded option to fzf
.
- --header-lines
: forwarded option to fzf
- --column
: forwarded option to fzf
.
- --delimiter
: forwarded option to fzf
.
The command for generating possible inputs can refer previous variables: ```sh
echo
$ x: echo '1 2 3' | tr ' ' '\n' $ y: echo "$((x+10)) $((x+20))" | tr ' ' '\n' ```
Commands may be multiline: ```sh
echo foo true \ && echo yes \ || echo no ```
Lists can be stylized with the $FZFDEFAULTOPTS environment variable or similar variables or parameters ( please refer to navi --help
). This way, you can change the color scheme, for example.
There are many similar projects out there (bro, eg, cheat.sh, tldr, cmdmenu, cheat, beavr, how2 and howdoi, to name a few).
Most of them provide excellent cheatsheet repositories, but lack a nice UI and argument suggestions.
In The Legend of Zelda Ocarina of Time, navi is a character that provides Link with a variety of clues to help him solve puzzles and progress in his quest.