# cheat.sh User Guide

**cheat.sh** is the command line's missing cheat sheet. It gives you instant,
copy-paste-ready answers to "how do I do X?" — for UNIX/Linux commands and 58
programming languages — directly from your terminal, your browser, or your code
editor, with nothing to install.

You ask a question by making an HTTP request. The answer comes back as plain
text you can paste straight into your shell or your program:

```bash
curl cheat.sh/tar
```

```text
# To extract an uncompressed archive:
tar -xvf /path/to/foo.tar

# To create an uncompressed archive:
tar -cvf /path/to/foo.tar /path/to/foo/

# To extract a .gz archive:
tar -xzvf /path/to/foo.tgz
...
```

That is the entire idea: a cheat sheet that is **concise**, **fast** (answers in
~100 ms), **comprehensive**, **universal** (works anywhere `curl` works), and
**unobtrusive**. This guide shows you everything you can do with it.

> [!NOTE]
> cheat.sh aggregates the best community-driven cheat sheet repositories in the
> world (tldr-pages, the `cheat` project, Learn X in Y Minutes, RosettaCode) plus
> StackOverflow. You are querying a unified front door to all of them at once.

---

## Table of Contents

1. [Quick Start](#1-quick-start)
2. [Two Ways to Use It](#2-two-ways-to-use-it)
3. [Installing the `cht.sh` Client](#3-installing-the-chtsh-client)
4. [Everyday Queries](#4-everyday-queries)
5. [Programming Language Cheat Sheets](#5-programming-language-cheat-sheets)
6. [Query Options](#6-query-options)
7. [Searching](#7-searching)
8. [Special Pages](#8-special-pages)
9. [The `cht.sh` Shell Mode](#9-the-chtsh-shell-mode)
10. [Tab Completion](#10-tab-completion)
11. [Stealth Mode](#11-stealth-mode)
12. [Editor Integration](#12-editor-integration)
13. [Recipes](#13-recipes)
14. [How It Works (Concepts)](#14-how-it-works-concepts)
15. [Troubleshooting](#15-troubleshooting)
16. [FAQ](#16-faq)
17. [Quick Reference](#17-quick-reference)

---

## 1. Quick Start

You do not need to install anything to start. If you have `curl` (or any HTTP
client), you are ready.

> [!TIP]
> Both names work and are interchangeable: the long form `cheat.sh` and the
> short form `cht.sh`. Use whichever you can type fastest.

**Get a cheat sheet for a UNIX/Linux command:**

```bash
curl cht.sh/rsync
```

**Get a programming-language answer:**

```bash
curl cht.sh/python/lambda
```

**Ask a free-form "how do I…" question** (separate words with `+`):

```bash
curl cht.sh/python/reverse+a+list
```

```text
# python - How do I reverse a list?

>>> L = [0, 10, 20, 40]
>>> L[::-1]
[40, 20, 10, 0]
```

**Search for a command when you don't know its name** (use `~`):

```bash
curl cht.sh/~snapshot
```

That is everything you need to be productive. The rest of this guide adds power
features: a dedicated client, syntax-highlight controls, shell mode, completion,
and editor integration.

> [!IMPORTANT]
> Use HTTPS for anything you care about: `curl https://cht.sh/tar`. Plain HTTP
> also works, but HTTPS protects the query and answer in transit.

---

## 2. Two Ways to Use It

There are two equally valid ways to talk to cheat.sh. Pick based on your taste.

| Approach | What it is | Best for |
|----------|-----------|----------|
| **Direct `curl`** | Raw HTTP requests to `cheat.sh/...` | Scripts, one-offs, zero setup, any machine |
| **`cht.sh` client** | A small shell script wrapper | Daily use: natural spacing, history, clipboard, shell mode, stealth |

The service automatically detects how you are connecting and formats the answer
accordingly:

- **Terminal tools** (`curl`, `wget`, `httpie`, `python-requests`, `xh`, `fetch`,
  PowerShell, and friends) receive **plain text with terminal colors** (ANSI).
- **Web browsers** receive a **formatted HTML page** with a search box.

So `curl cht.sh/go/Pointers` gives you pasteable text, while opening
`https://cht.sh/go/Pointers` in Chrome gives you a styled page.

> [!NOTE]
> The whole interface is "the URL is the question." There is no separate API to
> learn — the path *is* the query, and query-string letters like `?T` are the
> options. Section [6](#6-query-options) covers those.

---

## 3. Installing the `cht.sh` Client

The `cht.sh` client is optional but highly recommended for interactive daily use.
It is a **shell script** — not a Python or pip package — so you install it by
downloading the script and making it executable.

> [!CAUTION]
> There is no `pip install cht.sh`. cheat.sh is not published to PyPI, and trying
> to `pip install` it will fail. Use the `curl` method below (or the third-party
> `cht.exe` on Windows — see [section 12](#12-editor-integration)).

### Install for your user

=== "Linux / macOS (user)"

    ```bash
    PATH_DIR="$HOME/bin"   # any directory already on your $PATH
    mkdir -p "$PATH_DIR"
    curl https://cht.sh/:cht.sh > "$PATH_DIR/cht.sh"
    chmod +x "$PATH_DIR/cht.sh"
    ```

=== "Linux / macOS (global)"

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

The special page `:cht.sh` returns the source code of the client itself — that is
what you are downloading.

### Install the shell-mode dependency

Shell mode (section [9](#9-the-chtsh-shell-mode)) needs `rlwrap` for readline
support:

```bash
sudo apt install rlwrap     # Debian/Ubuntu
```

> [!TIP]
> Verify the install: `cht.sh --help` or `cht.sh tar`. If the command is found and
> returns a cheat sheet, you are done.

### Verify your install

- [ ] `cht.sh` is on your `$PATH` (`command -v cht.sh` prints a path)
- [ ] `cht.sh tar` returns a cheat sheet
- [ ] `rlwrap` is installed (only needed for `--shell`)

---

## 4. Everyday Queries

### Look up a UNIX/Linux command

```bash
curl cht.sh/tar
curl cht.sh/rsync
curl cht.sh/tr
```

With the client:

```bash
cht.sh tar
```

### Ask a programming question

Put the language first, then your question. **Separate words with `+`** when using
`curl`:

```bash
curl cht.sh/go/reverse+a+list
curl cht.sh/js/parse+json
curl cht.sh/lua/merge+tables
curl cht.sh/clojure/variadic+function
```

With the client you can use **real spaces** instead of `+`:

```bash
cht.sh go reverse a list
cht.sh js parse json
```

### Pick a different answer

If the first answer isn't what you wanted, append `/1`, `/2`, … to cycle through
alternatives:

```bash
curl cht.sh/python/random+string
curl cht.sh/python/random+string/1
curl cht.sh/python/random+string/2
```

### Exclude a word from the answer

Add the unwanted word with `+-` to filter it out — useful to avoid a particular
library:

```bash
curl cht.sh/python/multiply+matrices+-numpy
```

> [!TIP]
> Write better questions and you get better answers. Be specific
> (`python/append+file` beats `python/file`), ask practical questions, and name
> the language as the first path segment.

---

## 5. Programming Language Cheat Sheets

Language cheat sheets live in **namespaces** named after the language. cheat.sh
covers **58 languages** plus a few related topics (CMake, Django, Flask, Git).

For each language, several special sheets are available:

| Query | What you get |
|-------|--------------|
| `lua` | The main Lua cheat sheet |
| `lua/hello` | How to install, build, run, and a "Hello world" |
| `lua/:list` | All topics available for that language |
| `lua/:learn` | A full "Learn X in Y Minutes" tutorial sheet |
| `perl/1line` | A collection of one-liners (where available) |
| `js/weirdness` | Examples of the language's weird corners (where available) |

```bash
curl cht.sh/go/:list       # list all Go topics
curl cht.sh/python/:learn  # Python basics tour
curl cht.sh/lua/hello      # getting-started for Lua
```

### How answers are generated

If a cheat sheet already exists for your query, you get it directly. If not — which
is common for free-form questions — cheat.sh **generates an answer on the fly** from
the available cheat sheets and the best StackOverflow answers for that language. It
won't be a 100% guaranteed hit, but it is usually exactly what you needed.

> [!NOTE]
> Answers are formatted as valid code in the queried language, so you can paste
> them directly into a program. Explanatory text is rendered as comments in that
> language's syntax (`#`, `//`, `--`, etc.).

### Supported languages (prefixes)

```text
arduino  assembly awk      basic    bash     bf       c        chapel
clean    clojure  coffee   cpp      csharp   d        dart     delphi
dylan    eiffel   elixir   elisp    elm      erlang   factor   forth
fortran  fsharp   go       groovy   haskell  java     js       julia
kotlin   latex    lisp     lua      matlab   nim      ocaml    octave
perl     perl6    php      pike     python   python3  r        racket
ruby     rust     scala    scheme   solidity swift    tcl      tcsh
objective-c        vb       vbnet
```

Related (not languages): `cmake`, `django`, `flask`, `git`.

> [!TIP]
> Common aliases are understood automatically: `c++` → `cpp`, `c#` → `csharp`,
> `golang` → `go`, `js`/`javascript`, `sh` → `bash`, `objc` → `objective-c`,
> `f#` → `fsharp`, and more.

---

## 6. Query Options

Options are single letters appended to the query as a query string. When using
`curl` you must **escape the `?`** (or quote the URL) so your shell doesn't try to
glob it.

| Option | Effect |
|--------|--------|
| `?Q` | **Quiet** — remove the explanatory text, return code only |
| `?T` | **Text** — turn syntax highlighting (terminal colors) off |
| `?q` | Quiet rendering (suppress the page chrome in HTML) |
| `?c` | Drop comments, keep original indentation |
| `?C` | Drop comments and unindent the code |
| `?style=NAME` | Use a specific syntax-highlight color style |
| `?lang=XX` | Request answer in a human language (where supported) |

Combine options by stringing the letters together — `?QT` means "code only, no
colors":

```bash
curl cht.sh/python/random+list+elements\?Q
curl cht.sh/lua/merge+tables\?QT
curl "cht.sh/go/reverse+a+list?Q"     # quoting also works
```

Example — comments stripped with `?Q`:

```bash
curl cht.sh/lua/table+keys\?Q
```

```lua
local keyset={}
local n=0

for k,v in pairs(tab) do
  n=n+1
  keyset[n]=k
end
```

### Color styles

List the available highlight styles and preview them:

```bash
curl cht.sh/:styles         # names only
curl cht.sh/:styles-demo    # rendered examples
```

Then use one:

```bash
curl cht.sh/python/lambda\?style=native
```

> [!NOTE]
> The available style names come from Pygments (the highlighting library). If you
> ask for a style that isn't recognized, the default is used silently.

---

## 7. Searching

When you don't know the exact name of a command or topic, search with the `~`
notation. Search is **not recursive** by default — it only looks at the level you
specify.

```bash
curl cht.sh/~snapshot          # search top-level cheat sheets
curl cht.sh/scala/~currying    # search within the scala namespace
```

### Recursive search

Add `/r` (a search option after a closing slash) to search **all** cheat sheets:

```bash
curl cht.sh/~snapshot/r
```

### Search options

Append these letters after the closing slash:

| Option | Meaning |
|--------|---------|
| `i` | Case-insensitive |
| `b` | Match whole words (word boundaries) |
| `r` | Recursive (search every sheet) |

```bash
curl cht.sh/~shot/bi    # case-insensitive, whole-word match for "shot"
```

> [!NOTE]
> Searches are capped at the first 20 matching answers. If you hit the cap, a
> `LIMITED TO 20 ANSWERS` marker is appended so you know there may be more —
> narrow your keyword to see them.

---

## 8. Special Pages

Pages whose name starts with a colon (`:`) are not cheat sheets — they are built-in
helpers.

**Getting started:**

| Page | What it shows |
|------|---------------|
| `:help` | Description of all special pages and options |
| `:intro` | A guided introduction covering the most common usage |
| `:list` | List every available cheat sheet (works in a subsection: `go/:list`) |

**Client and shell support:**

| Page | What it shows |
|------|---------------|
| `:cht.sh` | The source code of the `cht.sh` client |
| `:bash_completion` | The bash tab-completion function |
| `:bash` | bash function + completion setup |
| `:fish` | fish function + completion setup |
| `:zsh` | zsh function + completion setup |

**Editor support:**

| Page | What it shows |
|------|---------------|
| `:vim` | cheat.sh support for Vim |
| `:emacs` | cheat.sh function for Emacs |
| `:emacs-ivy` | Emacs support for ivy users |

**Other pages:**

| Page | What it shows |
|------|---------------|
| `:post` | How to submit a new cheat sheet |
| `:styles` | List of color styles |
| `:styles-demo` | Color-style usage examples |
| `:random` | A random page (works in a subsection: `go/:random`) |

```bash
curl cht.sh/:help
curl cht.sh/:list
curl cht.sh/python/:random
```

> [!TIP]
> `curl cht.sh/:intro` is the fastest way to get the highlights of the service in
> one screen.

### Beyond cheat sheets: built-in tools

A few namespaces are computed, not stored:

```bash
curl cht.sh/chmod/644      # explain a chmod numeric mode
curl cht.sh/rfc/2616       # fetch an RFC by number
curl cht.sh/oeis/A000045   # look up an OEIS integer sequence
```

---

## 9. The `cht.sh` Shell Mode

Shell mode gives you a persistent, interactive prompt with history, a language
context, and clipboard integration. Start it with `--shell`:

```bash
cht.sh --shell
```

```text
cht.sh> go reverse a list
```

### Set a language context

If all your questions are about one language, set the context once with `cd` and
drop the language prefix:

```text
$ cht.sh --shell
cht.sh> cd go
cht.sh/go> reverse a list
cht.sh/go> join a list
```

You can also start directly in a context:

```bash
cht.sh --shell go
```

To run a one-off query in a *different* language without changing context, prefix
it with `/`:

```text
cht.sh/go> /python dictionary comprehension
```

### Internal shell commands

| Command | Aliases | What it does |
|---------|---------|--------------|
| `help` | | Show the in-shell help |
| `hush` | | Stop showing the help banner at startup |
| `cd LANG` | | Change the language context |
| `copy` | `yank`, `y`, `c` | Copy the last answer to the clipboard |
| `ccopy` | `cc`, `Y`, `C` | Copy the last answer **without** comments |
| `id [ID]` | | Set/show a session id (`reset` / `remove`) |
| `stealth` | | Enter stealth mode (see [section 11](#11-stealth-mode)) |
| `update` | | Self-update the client (if the script file is writable) |
| `version` | | Show the client version |
| `exit` | `quit`, `Ctrl-D` | Leave the shell |

Example — copy an answer without comments:

```text
cht.sh/python> append file
#  python - How do you append to a file?

with open("test.txt", "a") as myfile:
    myfile.write("appended text")
cht.sh/python> C
copy: 2 lines copied to the selection
```

### Client configuration file

The client reads `~/.cht.sh/cht.sh.conf` (override the location with the
`CHTSH_CONF` environment variable). Put query options you always want there:

```bash
# ~/.cht.sh/cht.sh.conf
CHTSH_QUERY_OPTIONS="T"            # always turn highlighting off
```

Other useful settings:

```bash
CHTSH_QUERY_OPTIONS="style=native" # always use a specific color style
CHTSH_CURL_OPTIONS="-A curl"       # extra curl options for every query
CHTSH_URL=https://cht.sh           # point the client at a different server
```

> [!TIP]
> `CHTSH_URL` lets you point the client at your own self-hosted instance. See the
> Admin Guide for how to run one.

---

## 10. Tab Completion

Tab completion lets you press <kbd>Tab</kbd> to complete language names and topics.

=== "Bash"

    ```bash
    curl https://cheat.sh/:bash_completion > ~/.bash.d/cht.sh
    . ~/.bash.d/cht.sh
    # add this line to ~/.bashrc to load it on every shell:
    #   . ~/.bash.d/cht.sh
    ```

=== "Zsh"

    ```zsh
    curl https://cheat.sh/:zsh > ~/.zsh.d/_cht
    echo 'fpath=(~/.zsh.d/ $fpath)' >> ~/.zshrc
    # open a new shell to load the plugin
    ```

=== "Fish"

    ```fish
    # fetch the fish setup function
    curl https://cheat.sh/:fish
    # follow the printed instructions to install it
    ```

> [!NOTE]
> These completion scripts are served live from the service, so they always match
> the current client.

---

## 11. Stealth Mode

Stealth mode lets you get answers **without touching the keyboard**. Once enabled,
any text you select with the mouse (into the X selection buffer or clipboard) is
sent as a query and the matching cheat sheet appears automatically.

Enter it from shell mode:

```text
$ cht.sh --shell python
cht.sh/python> stealth
```

Add the `Q` option to get **code only** (no commentary):

```text
cht.sh/python> stealth Q
stealth: you are in the stealth mode; select any text
stealth: selections longer than 5 words are ignored
stealth: query arguments: ?Q
stealth: use ^C to leave this mode
```

Now selecting the phrase "reverse a list" anywhere on your screen instantly prints:

```python
reverse_lst = lst[::-1]
```

Press <kbd>Ctrl-C</kbd> to leave stealth mode.

> [!IMPORTANT]
> Selections longer than 5 words are ignored, so ordinary reading won't trigger a
> flood of queries.

> [!CAUTION]
> The project's own documentation jokes about using this during interviews. Don't.
> Stealth mode is a genuinely useful pair-programming and learning tool — use it to
> learn faster, not to misrepresent your skills.

---

## 12. Editor Integration

You can query cheat.sh from your editor without switching to a browser. Each editor
plugin lives in its **own repository** (cheat.sh itself does not bundle them).

| Editor | Plugin |
|--------|--------|
| Vim | [`cheat.sh-vim`](https://github.com/dbeniamine/cheat.sh-vim) |
| Emacs | [`cheat-sh.el`](https://github.com/davep/cheat-sh.el) (also `cht.sh/:emacs`) |
| Visual Studio Code | [`vscode-snippet`](https://github.com/mre/vscode-snippet) |
| Sublime Text | [`cheat.sh-sublime-plugin`](https://github.com/gauravk-in/cheat.sh-sublime-plugin/) |
| IntelliJ IDEA | [`idea-cheatsh-plugin`](https://github.com/szymonprz/idea-cheatsh-plugin) |
| QtCreator | [`cheatsh-qtcreator`](https://github.com/pozemka/cheatsh-qtcreator) |

Feature support varies by editor:

| Feature | Emacs | Sublime | Vim | VSCode | IDEA | QtCreator |
|---------|:---:|:---:|:---:|:---:|:---:|:---:|
| Command queries | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Queries from buffer | | | ✓ | ✓ | | ✓ |
| Toggle comments | | | ✓ | ✓ | ✓ | ✓ |
| Prev/next answer | | | ✓ | ✓ | ✓ | ✓ |
| Multiple answers | | ✓ | | | ✓ | |
| Warnings as queries | | | ✓ | | | |
| Queries history | | | ✓ | ✓ | | |
| Session id | | | ✓ | | | |
| Configurable server | ✓ | | ✓ | ✓ | | ✓ |

### Vim example

With [`cheat.sh-vim`](https://github.com/dbeniamine/cheat.sh-vim) installed, type a
question directly in your buffer and press `<leader>KK` to see the answer in a
pager (`<leader>KB` for a separate buffer). `<leader>KP` pastes it below your
question; `<leader>KR` replaces the question; `<leader>KC` toggles comments. If you
use a linter such as *syntastic*, put the cursor on a warning line and press
`<leader>KE` to look up an explanation.

### Windows

There is no native Windows client in this repository. Use the third-party
[`cht.exe`](https://github.com/tpanj/cht.exe) (supports colorization, command-line
options, and its own config file). Install it with [scoop](https://github.com/lukesampson/scoop):

```batch
scoop install cht
```

---

## 13. Recipes

### Make a shell alias

```bash
# ~/.bashrc
cheat() { curl -s "cht.sh/$1"; }
# usage: cheat tar
```

### Get just the code, no colors, for piping

```bash
curl -s cht.sh/python/read+json\?QT
```

The `Q` strips prose and `T` strips ANSI color codes, leaving clean code suitable
for redirecting into a file or another program.

### Repeat your previous query

Set a session id (via a cookie or the client's `id` command), then request
`:last`:

```bash
# the cht.sh client manages this for you with `id`
curl -b "id=mysession" cht.sh/:last
```

> [!NOTE]
> `:last` requires a session id. Without one you get
> `ERROR: you have to set id for your requests to use /:last`. The `cht.sh` client
> sets the id for you when you run `id <name>` in shell mode.

### Submit your own cheat sheet

You can POST a cheat sheet to the service:

```bash
curl --data "$(cat my-cheatsheet.txt)" cht.sh/python/my-trick
```

See `curl cht.sh/:post` for the full instructions, and section
[16](#16-faq) for the recommended way to contribute lasting cheat sheets.

---

## 14. How It Works (Concepts)

You don't need this to use cheat.sh, but it explains the behavior you see.

**The URL is the query.** Everything after the host is your question. The first
path segment is usually a language or command; the rest is the topic. Query-string
letters (`?QT`) are options.

**Answers come from many sources, merged.** Behind the service is a set of
*adapters*, each wrapping one upstream cheat sheet repository or computed source:

| Source | Provides |
|--------|----------|
| `cheat.sheets` | The native cheat.sh sheets (UNIX/Linux + programming) |
| `tldr` | Simplified, example-driven man pages (tldr-pages) |
| `cheat` | Community command cheat sheets (the `cheat` project) |
| `learnxiny` | "Learn X in Y Minutes" language tours (the `:learn` pages) |
| `rosetta` | RosettaCode task implementations |
| `question` | On-the-fly answers from StackOverflow |
| `rfc`, `oeis`, `chmod` | Computed lookups (RFCs, integer sequences, file modes) |

When several sources can answer, you get multiple answers and can switch between
them with `/1`, `/2`, …

**Formatting adapts to you.** The service checks your User-Agent: terminal clients
get colored plain text, browsers get an HTML page. The `?T` option forces plain,
color-free text regardless.

> [!NOTE]
> For the architecture in depth — the routing table, caching, adapters, and how to
> run your own instance — see the **cheat.sh Admin Guide**.

---

## 15. Troubleshooting

### Error: `500 Internal Server Error`

**Cause:** A transient server-side error, often from an upstream source timing out
or a malformed query path. The `:shell-x/` proxy path is a known trigger.

**Solution:** Retry the query; simplify it; ensure your path doesn't contain stray
special characters. If it persists for a normal query, it is a service-side issue —
check the project's GitHub issues.

**Prevention:** Prefer specific, well-formed queries (`/python/append+file`). Avoid
internal proxy paths like `:shell-x` unless you know you need them.

### Error: `429 Not so fast! Number of queries per <interval> is limited to <N>`

**Cause:** You exceeded the per-IP rate limit. Limits apply to multi-word queries
(those containing `+`).

**Solution:** Slow down your request rate, or self-host an instance (see the Admin
Guide) where you control the limits.

**Prevention:** Cache answers locally in scripts; don't hammer the public service
in tight loops.

### Error: `Unknown topic. Do you mean one of these topics maybe?`

**Cause:** The topic name wasn't recognized. cheat.sh shows the three closest
matches.

**Solution:** Pick one of the suggestions, or rephrase. For a free-form question,
make sure you put the language first: `/python/<question>`.

**Prevention:** Use `:list` (e.g. `curl cht.sh/python/:list`) to see valid topics.

### Error: `404 NOT FOUND — Unknown cheat sheet. Please try to reformulate your query.`

**Cause:** No answer could be generated for a programming-language question.

**Solution:** Reformulate using the `/LANG/QUESTION` format, e.g.
`/python/read+json`, `/js/regex+search`. Use `+` between words.

**Prevention:** Be specific and practical; name the language explicitly.

### `pip install cht.sh` fails (especially on Windows)

**Cause:** cheat.sh is not a pip package. The client is a shell script.

**Solution:** Install via `curl https://cht.sh/:cht.sh > ~/bin/cht.sh && chmod +x ~/bin/cht.sh`
on Linux/macOS, or use [`cht.exe`](https://github.com/tpanj/cht.exe) on Windows.

**Prevention:** Don't use `pip` for the client — follow [section 3](#3-installing-the-chtsh-client).

### The install command hangs forever (macOS)

**Cause:** Usually a network stall fetching the script, or `rlwrap` not yet
installed when entering shell mode.

**Solution:** Re-run the `curl` install with `-s`; install `rlwrap`
(`brew install rlwrap`) before using `--shell`.

**Prevention:** Install `rlwrap` first; use HTTPS URLs.

### Shell mode prints an error about `rlwrap`

**Cause:** Shell mode (`--shell`) requires `rlwrap` for readline support.

**Solution:** `sudo apt install rlwrap` (Debian/Ubuntu) or `brew install rlwrap`
(macOS), then retry.

**Prevention:** Install `rlwrap` as part of setup ([section 3](#3-installing-the-chtsh-client)).

### A cheat sheet's content looks wrong or misleading

**Cause:** The content comes from a community upstream repository, not from
cheat.sh itself.

**Solution:** Fix it in the upstream repo — open the answer in a browser, click the
repository button at the bottom of the page, and edit it there. See
[section 16](#16-faq).

**Prevention:** None needed; this is how community content stays current.

### Light-mode browser themes are hard to read

**Cause:** The HTML output is tuned for dark backgrounds (solarized-dark palette).

**Solution:** Use a dark theme in your browser, or query from the terminal where
you control colors with `?style=` and `?T`.

---

## 16. FAQ

**Q: Do I need to install anything to use cheat.sh?**
No. Any HTTP client (`curl`, `wget`, a browser) works against the public service.
The `cht.sh` client is an optional convenience.

**Q: What's the difference between `cheat.sh` and `cht.sh`?**
Nothing — they are two names for the same service. `cht.sh` is just shorter to type.

**Q: Why use the `cht.sh` client instead of plain `curl`?**
The client lets you write queries with spaces instead of `+`, keeps a history,
integrates with your clipboard, offers a persistent shell mode, tab completion, and
stealth mode.

**Q: How do I get only the code, without comments or colors?**
Append `?QT` — `Q` removes the prose, `T` removes the terminal colors:
`curl cht.sh/go/reverse+a+list?QT`.

**Q: Can I get answers as JSON?**
No. The public service returns terminal text (ANSI) or an HTML page, chosen by your
User-Agent. There is no JSON API endpoint.

**Q: How are answers generated when no cheat sheet exists?**
cheat.sh synthesizes one from the available cheat sheets and the best StackOverflow
answers for your language. It is best-effort, not guaranteed.

**Q: How many languages are supported?**
58 programming languages, plus related topics (CMake, Django, Flask, Git) and over
a thousand UNIX/Linux commands.

**Q: How do I cycle through alternative answers?**
Append `/1`, `/2`, … to your query.

**Q: How do I exclude a library or keyword from an answer?**
Add it with `+-`, e.g. `python/multiply+matrices+-numpy`.

**Q: Can I search if I don't know the command name?**
Yes — use `~`: `cht.sh/~snapshot`. Add `/r` for a recursive search across all
sheets, and `i`/`b` for case-insensitive / whole-word matching.

**Q: How do I edit or add a cheat sheet?**
Edit the original upstream repository (the page's repository button links to it).
To add one, contribute it to an external repo, to
[`chubin/cheat.sheets`](https://github.com/chubin/cheat.sheets), or POST it via
`cht.sh/:post`.

**Q: Is there a Windows client?**
Yes, the third-party [`cht.exe`](https://github.com/tpanj/cht.exe), installable via
`scoop install cht`.

**Q: Can I run my own private instance?**
Yes — cheat.sh is self-hostable with Docker. See the Admin Guide.

**Q: Can I use it completely offline?**
You can self-host for offline cheat-sheet access, but the StackOverflow-backed
*question* answers are not available offline — that feature is not implemented.

**Q: How do I point a client or editor at my own server?**
Set `CHTSH_URL` for the `cht.sh` client, or use the "configurable server" option in
editors that support it.

---

## 17. Quick Reference

### Query forms

| Form | Meaning |
|------|---------|
| `cht.sh/COMMAND` | Cheat sheet for a UNIX/Linux command |
| `cht.sh/LANG/QUESTION` | Programming answer (`+` between words) |
| `cht.sh/LANG/QUESTION/2` | Alternative answer #2 |
| `cht.sh/LANG/Q+-WORD` | Exclude `WORD` from the answer |
| `cht.sh/~KEYWORD` | Search at the top level |
| `cht.sh/LANG/~KEYWORD` | Search within a language |
| `cht.sh/~KEYWORD/r` | Recursive search across all sheets |
| `cht.sh/LANG/:list` | List topics for a language |
| `cht.sh/LANG/:learn` | Learn-X-in-Y tutorial for a language |
| `cht.sh/LANG/:random` | A random page from a language |
| `cht.sh/chmod/644` · `/rfc/N` · `/oeis/AN` | Computed lookups |

### Options (append as `?...`)

| Option | Effect |
|--------|--------|
| `Q` | Code only, no prose |
| `T` | No syntax-highlight colors |
| `q` | Quiet page chrome (HTML) |
| `c` / `C` | Drop comments / drop comments + unindent |
| `style=NAME` | Pick a color style |
| `lang=XX` | Human-language preference |

### Search options (after closing slash)

| Option | Meaning |
|--------|---------|
| `i` | Case-insensitive |
| `b` | Whole words |
| `r` | Recursive |

### `cht.sh` client shell commands

| Command | Effect |
|---------|--------|
| `cd LANG` | Set language context |
| `c` / `C` | Copy last answer / without comments |
| `id [ID]` | Set/show session id |
| `stealth [Q]` | Enter stealth mode (Q = code only) |
| `update` · `version` · `hush` · `help` | Self-update · version · hide banner · help |
| `exit` / `Ctrl-D` | Leave the shell |

### Client environment variables

| Variable | Purpose |
|----------|---------|
| `CHTSH_URL` | Server URL (default `https://cht.sh`) |
| `CHTSH_QUERY_OPTIONS` | Default query options |
| `CHTSH_CURL_OPTIONS` | Extra curl options |
| `CHTSH_CONF` | Path to the client config file |

### Install in one line

```bash
curl https://cht.sh/:cht.sh > ~/bin/cht.sh && chmod +x ~/bin/cht.sh
```

---

_Generated June 2026 from chubin/cheat.sh at 031a5d3. AI-generated documentation. The library is checked by sampling (three repositories so far); this guide was not individually reviewed. Verify against the project before relying on it. Unofficial; not affiliated with or reviewed by the project._
