Guide · Open source
How to use cheat.sh: curl, cht.sh client and tips
Updated · written with AI from the project's own documentation and checked against our catalogue data
cheat.sh is a web service that returns short cheat sheets for Unix/Linux commands and programming languages. This guide shows you how to query it with curl, how to install the cht.sh client, and how to refine answers so you get the example you need. By the end you will be able to look up a command or a coding task from your terminal without opening a browser.
Quick start
- 1Try a curl query. Run curl cheat.sh/tar in your terminal to see a cheat sheet for a command you already know.
- 2Search by keyword. If you do not know the command name, use curl cht.sh/~snapshot style queries with ~ followed by a keyword.
- 3Ask a programming question. Query a language namespace with plus signs between words, such as curl cht.sh/python/random+list+elements.
- 4Install the client. Create a directory on your PATH, download cht.sh into it with curl, and make it executable with chmod +x.
- 5Install rlwrap for shell mode. If you want shell mode, install rlwrap. The source gives sudo apt install rlwrap for Debian and Ubuntu.
- 6Refine the output. Add \?Q to drop comments or \?T to drop highlighting, and use /1 or /2 to see alternative answers.
What cheat.sh is and when to use it
cheat.sh is a free, MIT-licensed project written in Python. It draws on community-maintained cheat sheet repositories and, for many programming questions, answers from StackOverflow. The service is available at https://cheat.sh/ and works from a terminal, a browser, or a code editor.
It suits developers who look up command flags and syntax often, students who want quick examples while learning a language, and people who prefer not to leave the terminal to search the web.
- Look up flags and syntax for Unix/Linux commands
- Get short examples for programming tasks
- Stay in the terminal or editor instead of switching to a search engine
Query cheat.sh with curl
The simplest way to use cheat.sh is to query it with curl, or any other HTTP/HTTPS client, and put the command name in the request. Both the long name (cheat.sh) and the short name (cht.sh) work, and both HTTP and HTTPS are accepted.
If you do not know the command name, use the ~KEYWORD notation to search. Separate words in a programming query with + instead of spaces.
- Put the command name after the host to get its cheat sheet
- Use ~KEYWORD to search when you do not know the command name
- Use /1, /2 and so on at the end of a query to see other answers
curl cheat.sh/tar
curl cht.sh/curl
curl https://cheat.sh/rsync
curl https://cht.sh/tr
curl cht.sh/~snapshotAsk programming language questions
Programming cheat sheets live in a namespace for each language. Use :list to see what is available for a language, and :learn for a basic introduction to a language. If there is no ready-made sheet, one is generated from the available cheat sheets and StackOverflow answers.
The source notes that generated answers are not guaranteed to be exact, so check important code before relying on it. Use more specific queries for better results, and use -word to exclude a term.
- Be specific: python/append+file is better than python/file
- Use :list to see available cheat sheets for a language
- Use :learn for a language basics overview
- Exclude a word with +-, for example python/multiply+matrices+-numpy
curl cht.sh/go/Pointers
curl cht.sh/go/:list
curl cht.sh/go/reverse+a+list
curl cht.sh/python/random+string/1Clean up the output with options
You can remove text comments with the \?Q option, and switch off syntax highlighting with \?T. The two can be combined. The source points to the full list of options in /:help.
- \?Q removes text comments from the answer
- \?T switches off syntax highlighting
- Combine them, for example \?QT
curl cht.sh/lua/table+keys\?Q
curl cht.sh/lua/merge+tables\?QTInstall the cht.sh client
The cht.sh client lets you type queries with spaces instead of +. Install it to a directory on your PATH. The example below uses $HOME/bin, but you can choose another directory on your PATH. Curl is required. The rlwrap package is needed only for shell mode, and the source gives sudo apt install rlwrap for Debian and Ubuntu.
To install it for all users instead, the README gives a command that writes to /usr/local/bin/cht.sh with sudo.
- Prerequisites: curl, and rlwrap only for shell mode
- Client features include shell mode, query history, clipboard integration, and tab completion for bash, fish and zsh
- Stealth mode is also available
PATH_DIR="$HOME/bin" # or another directory on your $PATH
mkdir -p "$PATH_DIR"
curl https://cht.sh/:cht.sh > "$PATH_DIR/cht.sh"
chmod +x "$PATH_DIR/cht.sh"
sudo apt install rlwrapUse the client and shell mode
With the client you can write queries in plain words. Shell mode keeps a persistent context, so you can set a language once with cd and then ask questions without repeating its name. You can also start the shell already inside a language context.
- cht.sh go reverse a list runs a one-off query
- cht.sh --shell starts shell mode
- cd go sets the language context inside shell mode
- /python sends a single query for another language
cht.sh go reverse a list
cht.sh --shell
cht.sh --shell goWhat people use it for
- Check the flags for a Unix/Linux command like tar or rsync without leaving the terminal
- Find a short example of a programming task, such as parsing JSON in JavaScript
- Learn the basics of a language using its :learn page
- Search for a command by what it does using ~KEYWORD
- Use the client's shell mode to keep one programming language as context while you work
Frequently asked questions
Is cheat.sh free?
The project is licensed under MIT, as stated in the README. The service is described as available everywhere with no installation needed, and it can also be installed for offline use.
Do I need to install anything to use cheat.sh?
No. You can query it with curl, a browser, or a code editor. The cht.sh client is optional, though the README describes it as very helpful.
What do I need to install the cht.sh client?
The source lists curl as a prerequisite. rlwrap is needed only for cht.sh shell mode, and the README gives sudo apt install rlwrap for Debian and Ubuntu.
Is the cheat.sh answer always correct?
No. The README notes that generated answers are not guaranteed to be exact. Check code before relying on it, and use /1 or /2 to view alternatives.
How is cheat.sh different from tldr or cheat?
Comparable projects listed for this item include tldr, cheat (cheat/cheat), navi and tealdeer. This guide does not compare features in detail, so check each project's documentation for differences.
Can I run cheat.sh offline or on my own server?
The README describes Docker and offline options for self-hosting and offline use. See its Self-Hosting and Docker sections for the steps.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
cheat.sh suits developers and students who look up command flags or short coding examples often and want to stay in the terminal or editor. It is not the right choice if you need fully verified answers or long-form documentation, since the README says generated answers are not guaranteed to be exact.
Install options & downloads