DEV Community

David Schmitz
David Schmitz

Posted on

Cheat sheets in your terminal

After listening to episode 283 of The Changelog Podcast, I decided, that I want to use the awesome cheat sheet repository at Devhints on the commandline.

This is what I came up with: if you want to read the cheat sheet for React, download the Gist below, save it as hint and just type:

$ hint react
Enter fullscreen mode Exit fullscreen mode

and, voila, the sheet appears.

This is what the tool looks in your terminal

The shell script needs both wget and mdless, which you can install using your favorite package manager. The sheets are fetched from Devhints.IO's Github repository.

Sheet files are cached in $HOME/.hack and can be refreshed using the --refresh command line argument.

If you like the idea of cheat sheets in your terminal, you might also want to checkout TLDR, which explains tools using examples - basically it just reverses the classic man pages ;)

Anyway...

Let me know if you have a better way or some idea for improving this tiny snippet:

This is a cross post of http://koenighotze.de/hack/devhints.html

Top comments (6)

Collapse
 
wbswbs profile image
Wolfgang Blessen

Is there a way to list all the cheat sheets, that are available ?

Collapse
 
johnphamous profile image
John Pham

Looking at the repo, you could fetch the page and iterate through all the .md files.

Collapse
 
koenighotze profile image
David Schmitz

...actually this is a cool idea. You type 'hack got' and get "did you mean hack git"

Collapse
 
hpcsc profile image
David Nguyen

this is an interesting idea. I modified the script a bit, just for fun: gist.github.com/hpcsc/bebea8b364a5...

What the modified script does:

  • use fzf to interactively select file
  • can be used to search for markdown file in any github repo, not only restricted to devhints.io. devhints.io is still the default github repo to search if no argument is provided
  • store caches files according to github owner/repo structure
Collapse
 
pichardoj profile image
J. Pichardo

Hi man, you might want to check the script, you missed a $ in lines 14 and 15, $CACHE_DIR.

Regards

Collapse
 
koenighotze profile image
David Schmitz

Thanks a lot ;) Updated.