$ curl cheat.sh/
## curl cht.sh

To access a cheat sheet you can simply issue a plain HTTP or HTTPS request
specifying the topic name in the query URL:

    curl cheat.sh/tar
    curl https://cheat.sh/tar

You can use the full service name, cheat.sh, or the shorter variant, cht.sh.
They are equivalent:

    curl https://cht.sh/tar
    curl https://cheat.sh/tar

The preferred access protocol is HTTPS, and you should use it always when possible.

Cheat sheets in the root namespaces cover UNIX/Linux commands.

Cheat sheets covering programming languages are located in subsections:

    curl cht.sh/go/func

All cheat sheets in a subsection can be listed using a special query :list :

    curl cht.sh/go/:list

There are several other special queries. All of them are starting with a colon.
See /:help for the full list of the special queries.


## Search

If a cheat sheet is too large, you can cut the needed part out using an
additional search parameter. In this case, only the paragraph that contains the
search term will be displayed:

    curl cht.sh/tar~extract

If the name of the cheat sheet is omitted, and only the serch query is specified,
all cheat sheets in the namespace are scanned, and the found occurrencies
are displayed:

    curl cht.sh/~extract


## Options

cheat.sh queries as well as search queries have many options.
They can be specified as a part of the query string in the URL, after ?.
Short single letter options could be written all jointly together,
and long options are separated with &. For example, to switch 
syntax highlighting off the T switch is used:

    curl cht.sh/tar?T

Full list of all available cheat.sh options as well as description of all modes
of operation can be found in /:help,

    curl cht.sh/:help


## cht.sh client

Though it's perfectly possible to access cheat.sh using curl (or any other
HTTP client) alone, there is a special client, that has several advantages
comparing to plain curling: cht.sh.

To install the client in ~/bin:

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

Queries look the same, but you can separate words in the query with spaces,
instead of + as when using curl, what looks more natural:

    cht.sh python zip lists


## cht.sh shell

If you always issuing queries about the same programming language, it's can be
more convenient to run the client in the shell mode and specify the queries
context:

    $ cht.sh --shell python
    cht.sh/python> zip lists

Of course, you can start the shell without the context too:

    $ cht.sh --shell
    cht.sh> python zip lists
    cht.sh> go http query
    cht.sh> js iterate list

If you ue predominantly one language but sometime issuing queries about other,
you may prepend the query with /:

    cht.sh/python> zip lists
    cht.sh/python> /go http query
    cht.sh/python> /js iterate list


## :learn

If you are just start learning a new programming language, and you have no
distinct queries for the moment, cheat.sh can be a good starting point too. As
you know, it exports cheat sheets from the best cheat sheet repositories, and
one of them is Learn X in Y, a repository of concise documentation devoted
to learning programming languages from scratch (and not only them).

If you want start learning a new programming language, do (use less -R because
the output could be quite big): 

    curl cht.sh/elixir/:learn | less -R

Or simply :learn with cht.sh (you don't need less -R here, because
cht.sh starts pager if needed automatically):

    cht.sh/elixir> :learn


## Programming languages questions

One of the most important features of cheat.sh is that you can ask it any
questions about programming languages and instantly get answers on them. You
can use both direct HTTP queries or the cht.sh client for that:

    curl cht.sh/python/reverse+list
    
    cht.sh/python> reverse list

In the latter case you don't need + to separate the words in the query, you can
do it in a more natural way, with spaces.

If context in the cht.sh shell is not specified, you have to write the
programming language name as the first word in the query:

    cht.sh> python reverse list

But if you are using only one programming language and all queries are about
it, it's better to change the current context and 


## Comments

Text in the answers is syntactically formatted as comment in the correspondent
programming language

When using cht.sh, you can copy the result of the last query into the selection
buffer (you may also call it "clibpoard") using C (or c, with text):

    cht.sh/python> reverse list
    ...
    cht.sh/python> C
    1 lines copied


## bash TAB-completion for cht.sh

One of the advantages of the cht.sh client comparing to plain curl is that you
can use TAB completion when writing its queries in bash
(other supported shells: zsh and fish).

Install the TAB completion script for that. Assuming you use bash, you have to do:

    mkdir -p ~/.bash.d/
    curl https://cht.sh/:bash_completion > ~/.bash.d/cht.sh
    echo 'source ~/.bash.d/cht.sh' >> ~/.bashrc
    source ~/.bash.d/cht.sh


## Editor

You can access cheat.sh directly from editors: Vim and Emacs.
It's a very important feature! You should absolutely like it.

Imagine:
instead of switching to your browser, googling, browsing Stack Overflow
and eventually copying the code snippets you need and later pasting them into
the editor, you can achieve the same instantly and without leaving
the editor at all!

Here is how it looks like:

1. In Vim, if you have a question while editing a program, you can just type
your question directly in the buffer and press <leader>KK. You will get
the answer to your question in pager. (with <leader>KB you'll get the answer
in a separate buffer).

2. If you like the answer. You can manually paste it from the buffer or
the pager, or if you are lazy you can use <leader>KP to paste it under
your question (<leader>KR will replace your question). If you want the
answer without the comments, <leader>KC replays the last query
toggling them.

You have to install cheat.sh Vim/Emacs plugins for the editor support.
See /:vim or /:emacs with the detailed installation instructions.


## Feature requests, feedback and contribution

If you want to submit a new community driver repository for cheat.sh please
open a ticket on the project page on GitHub.

If you want to modify an existing cheat sheet, please check the source of the
cheat sheet (it is always displayed in the cheat sheet bottom line).

If you want to add a new cheat sheet, add it here:
https://github.com/chubin/cheat.sheets

If you want to suggest a new feature for cheat.sh, or if you've found a bug,
please open a new issue on github:
https://github.com/chubin/cheat.sh

If you want to get the major project updates, follow @igor_chubin in Twitter
or this RSS feed: https://twitrss.me/twitter_user_to_rss/?user=igor_chubin

$
Follow @igor_chubin cheat.sh