
cheat.sh is a tool that gives you quick access to a vast collection of community-driven cheat sheets. It covers 56 programming languages, several database systems, and over 1000 essential UNIX/Linux commands. Think of it as a one-stop shop for finding concise, practical coding and system administration tips without wading through endless search results.
Imagine the perfect cheat sheet: short, fast, comprehensive, available everywhere, and easy to use without pulling you away from your work. cheat.sh aims to be just that. It’s designed to help you find answers instantly, learn as you go, and even use it discreetly if needed. You can access it via a browser, curl, or a dedicated command-line client called cht.sh
, with features like auto-complete and a stealth mode for seamless use.
How to Use cheat.sh
You can query cheat.sh directly from the command line using curl
. For example, to get a cheat sheet for the tar
command, run:
curl cheat.sh/tar
You can also use the shorter domain:
curl cht.sh/curl
For programming languages, specify the language and topic, like:
curl cht.sh/python/lambda
curl cht.sh/go/Pointers
If you’re unsure of the exact command or topic, search with a keyword using ~
:
curl cht.sh/~snapshot
To explore all topics for a language, use :list
:
curl cht.sh/go/:list
For beginners, the :learn
page offers a quick introduction to a language’s basics:
curl cht.sh/lua/:learn
If a specific cheat sheet doesn’t exist, cheat.sh generates one on the fly using community resources like StackOverflow. To refine results, add /1
, /2
, etc., to cycle through alternative answers:
curl cht.sh/python/random+string/1
To keep answers clean, use ?Q
to remove comments or ?T
to disable syntax highlighting:
curl cht.sh/lua/table+keys?QT
Command-Line Client: cht.sh
The cht.sh
client makes things even easier. Install it with:
curl https://cht.sh/:cht.sh > ~/bin/cht.sh
chmod +x ~/bin/cht.sh
For global installation:
curl -s https://cht.sh/:cht.sh | sudo tee /usr/local/bin/cht.sh && sudo chmod +x /usr/local/bin/cht.sh
You’ll need rlwrap
for shell mode:
sudo apt install rlwrap
With the client, queries are simpler, using spaces instead of +
:
cht.sh python random list elements
Start the client in shell mode for a more interactive experience:
cht.sh --shell
You can focus on a single language:
cht.sh --shell python
cht.sh/python> reverse a list
Copy answers to your clipboard with c
(with comments) or C
(without comments).
Tab Completion
Add tab completion for Bash:
curl https://cheat.sh/:bash_completion > ~/.bash.d/cht.sh
. ~/.bash.d/cht.sh
For ZSH:
curl https://cheat.sh/:zsh > ~/.zsh.d/_cht
echo 'fpath=(~/.zsh.d/ $fpath)' >> ~/.zshrc
Stealth Mode
Stealth mode lets you get cheat sheets without typing. Select text with your mouse, and cht.sh
fetches the answer automatically. Start it with:
cht.sh --shell python
cht.sh/python> stealth Q
This is perfect for quick lookups during coding sessions or even interviews (though, of course, use it ethically!).
Editor Integration
cheat.sh integrates with editors like Vim, Emacs, Visual Studio Code, Sublime, IntelliJ IDEA, and QtCreator. For example, in Vim, install the plugin:
Bundle 'dbeniamine/cheat.sh-vim'
Then, type a question, press <leader>KK
, and get the answer in a pager. Paste it with <leader>KP
or replace your question with <leader>KR
. Check the cheat.sh website for setup guides for other editors.
Self-Hosting with Docker
To run cheat.sh locally (e.g., for offline use), use Docker:
docker-compose up
This sets up the service at http://localhost:8002
. It’s great for personal or development use but not yet production-ready.
Programming Languages and Topics
cheat.sh supports 58 programming languages, including Python, Go, JavaScript, C++, and more. Each language has special pages like:
hello
: Shows how to set up and write a “Hello World” program.:list
: Lists all topics for the language.:learn
: A beginner-friendly overview.1line
: One-liner examples (for some languages).
For example:
curl cht.sh/python/:learn
curl cht.sh/perl/1line
Non-language topics like Git, CMake, and Flask are also covered.
Contributing to cheat.sh
To edit a cheat sheet, find its source repository (linked at the bottom of the cheat sheet page) and submit changes via GitHub. To add a new cheat sheet, either contribute to an existing repository, add it to cheat.sh’s own repository, or post it directly:
curl cheat.sh/:post
To suggest a new repository, open an issue on GitHub.
Why cheat.sh Stands Out
cheat.sh pulls from top-notch sources like tldr-pages, learnxinyminutes, and StackOverflow, ensuring high-quality, community-vetted content. It’s fast (answers in ~100ms), accessible everywhere, and designed to fit into your workflow without distraction. Whether you’re a beginner learning a new language or a pro needing a quick reference, cheat.sh has you covered.