navi - an interactive cheatsheet tool for the command-line
Posted on May 18, 2022 by Adrian Wyssmann ‐ 3 min read
While I am already fond of cheat.sh and pet, I found another exciting tool, navi
What is it
What I actually love, is that navi combines two nice features I have seen in other tools. One is the support of multiple sources - like cheat.sh - and the use of parametrized commands and executes them - just like pet.
How to use it
After installation, you can just type navi
, which does not yet provide that much info. So you can type navi repo browse
to browse featured cheatsheets and download them locally, so navi uses them.
It uses fzf for searching, which is very powerful. Once you select the comment it eventually asks you to provide the parameters, if the command expects some. Once you hit enter it runs the command. The downside of this is, that the command you have executed. To overcome this, you can install it as a shell widget, so you can hit Ctrl+G
to open navi:
You can use cheatsheets from tldr using --tldr
or cheat.sh using --cheatsh
. So for example, let’s search for ansible
stuff in cheat.sh
As you can see, the command is not executed yet but shown in the command line - so you still can modify it before executing it.
Limit search
One nice feature is the ability to limit your search to certain tags, by using --tag-rules
. For example navi --tag-rules git
would only offer snippets, tagged with git
.
You can also exclude tags. navi --tag-rules='git,!branch'
will show snippets which contain the tag git
, but not the tag branch
. I also tried to only exclude tags like navi --tag-rules='!fly'
, this however did not work (yet).
Your own cheatsheets
Also very cool is, that you can create your own cheatsheets, using it’s own [cheatsheet syntax]. You can import cheatsheets from any git repository that includes .cheat
files, so I created my own repo, currently with one cheatsheet kubernetes.cheat
I then add this to the collection of cheats:
Parametrization
cheetsheet syntax allows you to use list
$
: should contain commands that generate a list of possible values for a given argument information_source
So let’s have a command like this
The <context>
can be read by kubectl
so I define this in my cheat-sheet:
For the <object>
we define a list with pre-defined values:
Now let us see that in action:
Synchronizing cheatsheets
As mentioned in the documentation, auto-updating-repositories is not (yet) implemented. I currently use and adaption of this proposal and use git to synchronize:
Conclusion
navi is blazing fast and with using community driven cheatsheets, this is probably the only cheats tool you might want.