How to use cheat.sh in macOS Terminal

By Chip Loder

Terminal can be complex, so it's good that there's a single online repository of cheat sheets for it that can give you more information. Here's how to see it.

Igor Chubin

has created a Terminal-based online cheatsheet tool, called cheat.sh. While mainly targeted at developers, the cheat.sh project also includes a huge worldwide user-contributed base of cheat sheets for general Terminal commands, databases, and other useful macOS shortcuts.

While a little daunting to use at first for novice Terminal users, you'll soon have the hang of it and wonder how you got along without it.

How to use cheat.sh

There are 2 ways to use cheat.sh. The first, and easiest is simply to type 'curl' in a Terminal window followed by "cheat.sh", a slash, then a command or technology you want to look up. For example, to get full information on the UNIX tar command, in Terminal type curl cheat.sh/tar and press Return.

cheat.sh will respond with everything it knows about the tar command.

You can also get some examples of usage by typing curl cheat.sh and pressing Return.

The cheat.sh command uses the standard curl downloader tool for most access. But it also has built-in intelligence and natural-language processing which makes searching for what you want easy too.

If you don't know the exact name of a command or technology, you can use cheat.sh's search/lookup simply by prepending a "~" to any word at the end of a command. For example curl cheat.sh/~snapshot returns all info cheat.sh knows about how to take a system snapshot.

You can further refine searches by prefixing a keyword or command with a specific technology or language name as if accessing it by directory curl cheat.sh/go/Pointers.

For example returns all info cheat.sh knows about Pointers, but only for the go programming langauge.

Since most of the info returned is held in community-maintained cheat sheet databases, it's highly likely what you're looking for will be available. You can even add your own cheatsheet for any particular topic, provided you follow cheat.sh's guidelines.

You can view a list of all available cheat sheets on a topic by adding ":list" to the end of any query. For example curl cheat.sh/go/:list returns a list of all go programming topics in the cheat.sh system.

Command-line Client

There is also a dedicated command-line client for cheat.sh, which requires 2 commands in the Terminal to install. You'll need to have Homebrew installed to run the first command.

After Homebrew is installed, type brew install rlwrap then press Return.

Next, to install the cheat.sh command-line tool for all users on your Mac, in Terminal enter"

curl -s https://cht.sh/:cht.sh | sudo tee /usr/local/bin/cht.sh && sudo chmod +x /usr/local/bin/cht.sh

Then press Return.

As the documentation mentions:

A documentation Now you can use cht.sh instead of curl, and write your queries in more natural way.

There is also a complied binary (.exe) version of cheat.sh for Windows machines. It's also possible to install the entire cheat.sh system offline locally on your computer, although doing so is fairly technical, and might be beyond the ability of casual users. If we get enough requests, we'll cover it.

All-in-all cheat.sh is a valuable addition to your Terminal and tech knowledge. The ability to look up a command, or everything there is to know about a given technology in one place quickly is invaluable.