Scroll to navigation

cht.sh(1) cht.sh(1)

NAME

cht.sh - The only cheat sheet you need (command line client for cheat.sh)

SYNOPSIS

cht.sh [OPTIONS|QUERY]

DESCRIPTION

The cheat.sh service:

  • Covers 56 programming languages, several DBMSes, and more than 1000 most important UNIX/Linux commands.
  • Provides access to the best community driven cheat sheets repositories in the world, on par with StackOverflow.

The cheat.sh service has its own command line client (cht.sh) that has several useful features compared to querying the service directly with curl:

  • Special shell mode with a persistent queries context and readline support.
  • Queries history.
  • Clipboard integration.
  • Tab completion support for shells (bash, fish, zsh).
  • Stealth mode.

OPTIONS

process QUERY and exit.
print help.
shell mode (open LANG if specified).
install cheat.sh in the standalone mode (by default, into ~/.cheat.sh/).
set (or display) mode of operation:
  • auto - prefer the local installation
  • lite - use the cheat sheet server

EXAMPLES

Now, you can use cht.sh instead of curl, and write your queries in more natural way, with spaces instead of +:


$ cht.sh go reverse a list
$ cht.sh python random list elements
$ cht.sh js parse json
It is even more convenient to start the client in a special shell mode:


$ cht.sh --shell
cht.sh> go reverse a list
If all your queries are about the same language, you can change the context and spare repeating the programming language name:


$ cht.sh --shell
cht.sh> cd go
cht.sh/go> reverse a list
or even start the client in this context:


$ cht.sh --shell go
cht.sh/go> reverse a list
...
cht.sh/go> join a list
...
If you want to change the context, you can do it with the cd command, or if you want do a single query for some other language, just prepend it with /:


$ cht.sh --shell go
...
cht.sh/go> /python dictionary comprehension
...
If you want to copy the last answer into the clipboard, you can use the c (copy) command, or C (ccopy, without comments).


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
Type help for other internal cht.sh commands.


cht.sh> help
help - show this help
hush - do not show the 'help' string at start anymore
cd LANG - change the language context
copy - copy the last answer in the clipboard (aliases: yank, y, c)
ccopy - copy the last answer w/o comments (cut comments; aliases: cc, Y, C)
exit - exit the cheat shell (aliases: quit, ^D)
id [ID] - set/show an unique session id ("reset" to reset, "remove" to remove)
stealth - stealth mode (automatic queries for selected text)
update - self update (only if the scriptfile is writeable)
version - show current cht.sh version
/:help - service help
QUERY - space separated query staring (examples are below)
cht.sh> python zip list
cht.sh/python> zip list
cht.sh/go> /python zip list

AUTHOR

The cht.sh was written by Igor Chubin <igor@chub.in>.

This manual page was written by Thiago Marques Siqueira <thiagoms.15@gmail.com> for the Debian project (but may be used by others).

23 September 2023