Coder Social home page Coder Social logo

chubin / cheat.sh Goto Github PK

View Code? Open in Web Editor NEW
37.8K 582.0 1.8K 4.45 MB

the only cheat sheet you need

Home Page: https://cheat.sh/

License: MIT License

Python 67.37% Shell 30.41% HTML 1.26% CSS 0.24% Dockerfile 0.28% Go 0.34% Vim Script 0.09%
cheatsheet curl terminal command-line cli examples documentation help tldr hacktoberfest2021

cheat.sh's Introduction

cheat.sh logo

Unified access to the best community driven cheat sheets repositories of the world.

Let's imagine for a moment that there is such a thing as an ideal cheat sheet. What should it look like? What features should it have?

  • Concise — It should only contain the things you need, and nothing else.
  • Fast — It should be possible to use it instantly.
  • Comprehensive — It should contain answers for every possible question.
  • Universal — It should be available everywhere, anytime, without any preparations.
  • Unobtrusive — It should not distract you from your main task.
  • Tutoring — It should help you to learn the subject.
  • Inconspicuous — It should be possible to use it completely unnoticed.

Such a thing exists! It's easy to install and there's even auto-complete.

Features

cheat.sh

  • Has a simple curl/browser/editor interface.
  • 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.
  • Available everywhere, no installation needed, but can be installed for offline usage.
  • Ultrafast, returns answers within 100 ms, as a rule.
  • Has a convenient command line client, cht.sh, that is very advantageous and helpful, though not mandatory.
  • Can be used directly from code editors, without opening a browser and not switching your mental context.
  • Supports a special stealth mode where it can be used fully invisibly without ever touching a key and making sounds.

Contents

Usage

To get a cheat sheet for a UNIX/Linux command from a command line, query the service using curl or any other HTTP/HTTPS client specifying the name of the command in the query:

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

As you can see, you can use both HTTPS and HTTP to access the service, and both the long (cheat.sh) and the short (cht.sh) service names.

Here tar, curl, rsync, and tr are names of the UNIX/Linux commands you want to get cheat sheets for.

If you don't know the name of the command you need, you can search for it using the ~KEYWORD notation. For example, to see how you can make snapshots of a filesystem/volume/something else:

    curl cht.sh/~snapshot

The programming language cheat sheets are located in special namespaces dedicated to them.

    curl cht.sh/go/Pointers
    curl cht.sh/scala/Functions
    curl cht.sh/python/lambda

To get the list of available programming language cheat sheets, use the special query :list:

    curl cht.sh/go/:list

Almost each programming language has a special page named :learn that describes the language basics (that's a direct mapping from the "Learn X in Y" project). It could be a good starting point if you've just started learning a language.

If there is no cheat sheet for a programming language query (and it is almost always the case), it is generated on the fly, based on available cheat sheets and answers on StackOverflow. Of course, there is no guarantee that the returned cheat sheet will be a 100% hit, but it is almost always exactly what you are looking for.

Try these (and your own) queries to get the impression of that, what the answers look like:

    curl cht.sh/go/reverse+a+list
    curl cht.sh/python/random+list+elements
    curl cht.sh/js/parse+json
    curl cht.sh/lua/merge+tables
    curl cht.sh/clojure/variadic+function

If you don't like an answer for your queries, you can pick another one. For that, repeat the query with an additional parameter /1, /2 etc. appended:

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

Cheat sheets are formatted as code of the queried programming language (at least we are trying our best to do so) so they can be pasted into a program in this language directly. Text comments, if there are any, are formatted according to the language syntax.

    $ curl cht.sh/lua/table+keys
    -- lua: retrieve list of keys in a table

    local keyset={}
    local n=0

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

    --[[
       [ Note that you cannot guarantee any order in keyset. If you want the
       [ keys in sorted order, then sort keyset with table.sort(keyset).
       [ 
       [ [lhf] [so/q/12674345] [cc by-sa 3.0]
       ]]

If you don't need text comments in the answer, you can eliminate them using a special option \?Q:

    $ curl cht.sh/lua/table+keys\?Q
    local keyset={}
    local n=0

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

And if you don't need syntax highlighting, switch it off using \?T. You can combine the options together:

    curl cht.sh/go/reverse+a+list\?Q
    curl cht.sh/python/random+list+elements\?Q
    curl cht.sh/js/parse+json\?Q
    curl cht.sh/lua/merge+tables\?QT
    curl cht.sh/clojure/variadic+function\?QT

Full list of all options described below and in /:help.

Try your own queries. Follow these rules:

  1. Try to be more specific (/python/append+file is better than /python/file and /python/append).
  2. Ask practical question if possible (yet theoretical question are possible too).
  3. Ask programming language questions only; specify the name of the programming language as the section name.
  4. Separate words with + instead of spaces.
  5. Do not use special characters, they are ignored anyway.
  6. If you want to eliminate cheat sheets containing some word, add it to the query with +-: python/multiply+matrices+-numpy

Read more about the programming languages queries below.


Command line client, cht.sh

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.

Installation

To install the client:

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"

or to install it globally (for all users):

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

Note: The package "rlwrap" is a required dependency to run in shell mode. Install this using sudo apt install rlwrap

Client usage

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

The cht.sh client has its configuration file which is located at ~/.cht.sh/cht.sh.conf (location of the file can be overridden by the environment variable CHTSH_CONF). Use it to specify query options that you would use with each query. For example, to switch syntax highlighting off create the file with the following content:

CHTSH_QUERY_OPTIONS="T"

Or if you want to use a special syntax highlighting theme:

CHTSH_QUERY_OPTIONS="style=native"

(curl cht.sh/:styles-demo to see all supported styles).

Other cht.sh configuration parameters:

CHTSH_CURL_OPTIONS="-A curl"        # curl options used for cht.sh queries
CHTSH_URL=https://cht.sh            # URL of the cheat.sh server

Tab completion

Bash Tab completion

To activate tab completion support for cht.sh, add the :bash_completion script to your ~/.bashrc:

    curl https://cheat.sh/:bash_completion > ~/.bash.d/cht.sh
    . ~/.bash.d/cht.sh
    # and add . ~/.bash.d/cht.sh to ~/.bashrc

ZSH Tab completion

To activate tab completion support for cht.sh, add the :zsh script to the fpath in your ~/.zshrc:

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

Stealth mode

Being used fully unnoticed is one of the most important property of any cheat sheet.

cheat.sh can be used completely unnoticed too. The cheat.sh client, cht.sh, has a special mode, called stealth mode. Using that, you don't even need to touch your keyboard to open a cheat sheet.

In this mode, as soon as you select some text with the mouse (and thus adding it into the selection buffer of X Window System or into the clipboard) it's used as a query string for cheat.sh, and the correspondent cheat sheet is automatically shown.

Let's imagine, that you are having an online interview, where your interviewer asks you some questions using a shared document (say Google Docs) and you are supposed to write your coding answers there (it's possible too that you'll type in the questions on your own, just to show to the interviewer that you've heard it right).

When using the stealth mode of cht.sh, the only thing you need to do in order to see a cheat sheet for some question, is to select the question using the mouse. If you don't want any text in the answers and the only thing you need is code, use the Q option when starting the stealth mode.

You: Hi!                                            | $ cht.sh --shell python
She: Hi!                                            | cht.sh/python> stealth Q
She: Are you ready for a small interview?           | stealth: you are in the stealth mode; select any text
She: Just a couple of questions                     | stealth: selections longer than 5 words are ignored
She: We will talk about python                      | stealth: query arguments: ?Q
She: Let's start from something simple.             | stealth: use ^C to leave this mode
She: Do you know how to reverse a list in python?   |
You: Sure                                           |
You: (selecting "reverse a list")                   | stealth: reverse a list
                                                    | reverse_lst = lst[::-1]
You: lst[::-1]?                                     |
She: Good.                                          |
She: Do you know how to chain a list of lists?      |
You: (selecting "chain a list of lists")            | stealth: chain a list of lists
                                                    | import itertools
                                                    | a = [["a","b"], ["c"]]
                                                    | print list(itertools.chain.from_iterable(a))
You: May I use external modules?                    |
She: What module do you want to use?                |
You: itertools                                      |
She: Yes, you may use it                            |
You: Ok, then:                                      |
You: itertools.chain.from_iterable(a)               |
She: Good. Let's try something harder.              |
She: What about quicksort implementation?           |
You: (selecting "quicksort implementation")         | stealth: quicksort implementation
You: Let me think about it.                         | (some big and clumsy lowlevel implementation shown)
You: Well...(starting typing it in)                 | def sort(array=[12,4,5,6,7,3,1,15]):
                                                    |     less = []
She: (seeing your ugly pascal style)                |     equal = []
She: Could you write it more concise?               |     greater = []
                                                    |     if len(array) > 1:
You: What do you mean?                              |         pivot = array[0]
                                                    |         for x in array:
She: I mean,                                        |             if x < pivot: less.append(x)
She: do you really need all these ifs and fors?     |             if x == pivot: equal.append(x)
She: Could you maybe just use filter instead?       |             if x > pivot: greater.append(x)
                                                    |         return sort(less)+equal+sort(greater)
You: quicksort with filter?                         |     else:
                                                    |         return array
She: Yes                                            |
You: (selecting "quicksort with filter")            | stealth: quicksort with filter
You: Ok, I will try.                                | return qsort(filter(lt, L[1:]))+[pivot] \
You: Something like this?                           |     +qsort(filter(ge, L[1:]))
You: qsort(filter(lt, L[1:]))+[pivot] \             |
       + qsort(filter(ge, L[1:]))                   |
                                                    |
She: Yes! Perfect! Exactly what I wanted to see!    |
                                                    |

Of course, this is just for fun, and you should never cheat in your coding interviews, because you know what happens when you do.

when you lie in your interview

Windows command line client

You can access cheat.sh from Windows command line too.

Use cheat.sh command line client for that: cht.exe. It supports:

  • output colorization;
  • command line options;
  • its own configuration file.

You can also use scoop command-line installer for Windows to get it:

scoop install cht

Self-Hosting

Docker

Currently, the easiest way to get a self-hosted instance running is by using the docker-compose.yml file.

docker-compose up

This builds and runs the image with baked in cheatsheets and starts the app and a Redis instance to back it, making the service available at http://localhost:8002 This is currently an early implementation and should probably not be used for anything outside of internal/dev/personal use right now.

Editors integration

You can use cheat.sh directly from the editor (Emacs, Sublime, Vim, and Visual Studio Code are currently supported; not all features are supported by all plugins though; see below). Instead of opening your browser, googling, browsing Stack Overflow and eventually copying the code snippets you need into the clipboard and later pasting them into the editor, you can achieve the same instantly and without leaving the editor at all!

Here is what it looks like in Vim:

  1. 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 below/under your question (or replace you question using <leader>KR). If you want the answer without the comments, <leader>KC replays the last query toggling them.

If you use some static analysis plugin such as syntastic (for Vim), you can use its warning and error messages as cheat.sh queries: place the cursor on the problem line and press <leader>KE: explanation for the warning will be opened in a new buffer.

Features supported by cheat.sh plugins for different editors:

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

Here is Vim configuration example:

" some configuration above ...

let mapleader=" "

call vundle#begin()
Bundle 'gmarik/vundle'
Bundle 'scrooloose/syntastic'
Bundle 'dbeniamine/cheat.sh-vim'
call vundle#end()

let g:syntastic_javascript_checkers = [ 'jshint' ]
let g:syntastic_ocaml_checkers = ['merlin']
let g:syntastic_python_checkers = ['pylint']
let g:syntastic_shell_checkers = ['shellcheck']

" some configuration below ...

In this example, several Vim plugins are used:

Syntastic shows warnings and errors (found by code analysis tools: jshint, merlin, pylint, shellcheck etc.), and cheat.sh-vim shows you explanations for the errors and warnings and answers on programming languages queries written in the editor.

Watch a demo, where the most important features of the cheat.sh Vim plugin are shown (5 Min):

Or, if you want to scroll and/or pause, the same on YouTube:

cheat.sh-vim: Using cheat.sh from vim

Emacs

  • cheat-sh.el — Emacs support (available also at cheat.sh/:emacs)
  • cheat.sh/:emacs-ivy — Emacs support for ivy users

asciicast

Visual Studio Code

Usage:

  1. Hit ⌘ Command + ⇧ Shift + p
  2. Run Snippet: Find.
  3. Type your query and hit enter.

vscode-snippet

(GIF courtesy: Matthias Endler, @mre)

Sublime

Usage:

  1. Write your query string.
  2. Select the query string.
  3. Press Cmd + ⇧ Shift + B to replace the selected query string by the answer generated from cht.sh.

cheat.sh-sublime-plugin-demo

(GIF courtesy: Gaurav Kukreja, @gauravk-in)

IntelliJ IDEA

Usage:

  1. Write query string
  2. Select the query string
  3. Press keyboard shortcut Alt + C , S to replace the selected query string by the answer

idea-cheatsh-plugin

(GIF courtesy: Szymon Przebierowski, @szymonprz)

QtCreator

Current features:

  • search word under cursor
  • search selected
  • query search
  • disable comments
  • paste answer (?TQ version)
  • custom server URL
  • custom search context (default is cpp)
  • hotkeys and menu

cheatsh-qtcreator

(GIF courtesy: Pozemka, @pozemka)

Special pages

There are several special pages that are not cheat sheets. Their names start with colon and have special meaning.

Getting started:

    :help               description of all special pages and options
    :intro              cheat.sh introduction, covering the most important usage questions
    :list               list all cheat sheets (can be used in a subsection too: /go/:list)

Command line client cht.sh and shells support:

    :cht.sh             code of the cht.sh client
    :bash_completion    bash function for tab completion
    :bash               bash function and tab completion setup
    :fish               fish function and tab completion setup
    :zsh                zsh function and tab completion setup

Editors support:

    :vim                cheat.sh support for Vim
    :emacs              cheat.sh function for Emacs
    :emacs-ivy          cheat.sh function for Emacs (uses ivy)

Other pages:

    :post               how to post new cheat sheet
    :styles             list of color styles
    :styles-demo        show color styles usage examples
    :random             fetches a random page (can be used in a subsection too: /go/:random)

Search

To search for a keyword, use the query:

    /~keyword

In this case search is not recursive — it is conducted only in a page of the specified level. For example:

    /~snapshot          look for snapshot in the first level cheat sheets
    /scala/~currying     look for currying in scala cheat sheets

For a recursive search in all cheat sheets, use double slash:

    /~snapshot/r         look for snapshot in all cheat sheets

You can use special search options after the closing slash:

    /~shot/bi           case insensitive (i), word boundaries (b)

List of search options:

    i   case insensitive search
    b   word boundaries
    r   recursive search

Programming languages cheat sheets

Cheat sheets related to programming languages are organized in namespaces (subdirectories), that are named according to the programming language.

For each supported programming language there are several special cheat sheets: its own sheet, hello, :list and :learn. Say for lua it will look like:

    lua
    lua/hello
    lua/:list
    lua/:learn

Some languages has the one-liners-cheat sheet, 1line:

    perl/1line
  • hello describes how you can start with the language — install it if needed, build and run its programs, and it shows the "Hello world" program written in the language;
  • :list shows all topics related to the language
  • :learn shows a learn-x-in-minutes language cheat sheet perfect for getting started with the language.
  • 1line is a collection of one-liners in this language
  • weirdness is a collection of examples of weird things in this language

cheat.sh usage

At the moment, cheat.sh covers the 58 following programming languages (alphabetically sorted):

Prefix Language Basics One-liners Weirdness StackOverflow
arduino/ Arduino
assembly/ Assembly
awk/ AWK
bash/ Bash
basic/ BASIC
bf/ Brainfuck
c/ C
chapel/ Chapel
clean/ Clean
clojure/ Clojure
coffee/ CoffeeScript
cpp/ C++
csharp/ C#
d/ D
dart/ Dart
delphi/ Dephi
dylan/ Dylan
eiffel/ Eiffel
elixir/ Elixir
elisp/ ELisp
elm/ Elm
erlang/ Erlang
factor/ Factor
fortran/ Fortran
forth/ Forth
fsharp/ F#
go/ Go
groovy/ Groovy
haskell/ Haskell
java/ Java
js/ JavaScript
julia/ Julia
kotlin/ Kotlin
latex/ LaTeX
lisp/ Lisp
lua/ Lua
matlab/ MATLAB
nim/ Nim
ocaml/ OCaml
octave/ Octave
perl/ Perl
perl6/ Perl 6
php/ PHP
pike/ Pike
python/ Python
python3/ Python 3
r/ R
racket/ Racket
ruby/ Ruby
rust/ Rust
scala/ Scala
scheme/ Scheme
solidity/ Solidity
swift/ Swift
tcsh/ Tcsh
tcl/ Tcl
objective-c/ Objective-C
vb/ VisualBasic
vbnet/ VB.Net

And several other topics, that are though related to programming, are not programming languages:

Prefix Topic Basics StackOverflow
cmake/ CMake
django/ Django
flask/ Flask
git/ Git

Cheat sheets sources

Instead of creating yet another mediocre cheat sheet repository, we are concentrating our efforts on creation of a unified mechanism to access selected existing well developed and good maintained cheat sheet repositories covering topics of our interest: programming and operating systems usage.

cheat.sh uses selected community driven cheat sheet repositories and information sources, maintained by thousands of users, developers and authors all over the world (in the Users column number of contributors/number of stars is shown):

Cheat sheets Repository C/U* Stars Creation Date
UNIX/Linux, programming cheat.sheets May 1, 2017
UNIX/Linux commands tldr-pages/tldr Dec 8, 2013
UNIX/Linux commands chrisallenlane/cheat Jul 28, 2013
Programming languages adambard/learnxinyminutes-docs Jun 23, 2013
Go a8m/go-lang-cheat-sheet Feb 9, 2014
Perl pkrumnis/perl1line.txt Nov 4, 2011
Programming languages StackOverflow 14M N/A Sep 15, 2008

(*) C/U — contributors for GitHub repositories, Users for Stackoverflow

Pie diagram reflecting cheat sheets sources distribution (by number of cheat sheets on cheat.sh originating from a repository):

cheat.sh cheat sheets repositories

How to contribute

How to edit a cheat sheet

If you want to edit a cheat.sh cheat sheet, you should edit it in the upstream repository. You will find the name of the source repository in a browser when you open a cheat sheet. There are two github buttons at the bottom of the page: the second one is the button of the repository, which belongs the current cheat sheet.

You can edit the cheat sheet directly in your browser (you need a github account for it). There is an edit button in the top right corner. If you click on it, an editor will be open. There you will change the cheat sheet (under the hood: the upstream repository is forked, your changes are committed in the forked repository, a pull request to the upstream repository owner is sent).

cheat.sh cheat sheets repositories

How to add a cheat sheet

If you want to add a cheat sheet, you have one of the following ways:

  • Add it to one of the external cheat sheets repositories; you should decide on your own what is the best repository for your cheat sheet;
  • Add it to the local cheat.sh repository (cheat.sheets) on github (fork, commit, pull request);
  • Post it on cheat.sh using curl or a web browser (cheat.sh/:post).

If you want to change an existing cheat sheet, you have to find the original repository (when you open a cheat sheet in a browser, you see the repository's github button in the bottom of the cheat sheet), the cheat sheet is coming from, and change it there. After some time the changes will be synchronized on cheat.sh.

How to add a cheat sheet repository

If you want to add a cheat sheet repository to cheat.sh, please open an issue:

Please specify the name of the repository, and give its short description.

Installation and standalone usage

You don't need to install anything, to start using cheat.sh.

There are two cases, when you want to install cheat.sh locally:

  1. You plan to use it off-line, without Internet access;
  2. You want to use your own cheat sheets (additionally, or as a replacement).

Installation process in described in details here: cheat.sh standalone installation

cheat.sh's People

Contributors

abitrolly avatar albonycal avatar bglopez avatar bl-ue avatar chubin avatar codelongandprosper90 avatar davep avatar fedebuonco avatar floer32 avatar gpazuch avatar grayed avatar greenchili avatar jan200101 avatar joerho avatar joeyciechanowicz avatar johnnadratowski avatar madsmtm avatar md2perpe avatar mre avatar neuhaus avatar rajesh-s avatar ray-g avatar sea-n avatar seirdy avatar strikingloo avatar szymonprz avatar thezeroalpha avatar tsevans avatar waldyrious avatar wandex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cheat.sh's Issues

Wrong special query returns message about high load

cht.sh returns message about high load if special query is not defined or not understood:

+ $ curl -s cht.sh/python/: | head -3
#  Sorry, we are experiencing extremely highload now.
#  We are working on the problem and hope to get it fixed soon.
#  Please come back in several hours or try some other queries:
+ $ curl -s cht.sh/bash/: | head -3
# Sorry, we are experiencing extremely highload now.
# We are working on the problem and hope to get it fixed soon.
# Please come back in several hours or try some other queries:
+ $ curl -s cht.sh/bash/:foobar | head -3
# Sorry, we are experiencing extremely highload now.
# We are working on the problem and hope to get it fixed soon.
# Please come back in several hours or try some other queries:

cheat.sh/:wanted does not exist

cheat.sh/:post makes the following reference to cheat.sh/:wanted

If you want contribute to the project, but you have no idea what
cheat sheet you should post, check the list of the most wanted cheat sheets:

cheat.sh/:wanted

But apparently that page does not exist and instead shows 'Unknown topic'.

when mistyping, gives error of highload

curl cht.sh/ruby/lamba
# Sorry, we are experiencing extremely highload now.
# We are working on the problem and hope to get it fixed soon.
# Please come back in several hours or try some other queries:
#
# For example:

 curl cht.sh/:list               to list available cheat sheets
 curl cht.sh/LANGUAGE/:list      to list available cheat sheets for LANGUAGE
 curl cht.sh/LANGUAGE/:learn     to learn the LANGUAGE

i misspelled lambda and it gave me that error. Seems like it should tell me i'm wrong instead

Hardcoded configuration location in client.

Path ~/.cht.sh/ is hard-coded as the client configuration location in the client. Would it be possible to make the client configuration location configurable. The XDG Base Directory Specification might also provide a sensible default location.

How to change style?

I tried

cht.sh python reversed a list style=xcode
cht.sh> python reverse a list style=xcode

They are clearly not xcode. Thanks!

Add documentation to run your own mirror

Running python srv.py gave an import error.

$ python bin/srv.py
Traceback (most recent call last):
File "bin/srv.py", line 9, in
from gevent.wsgi import WSGIServer
ImportError: No module named wsgi

Would you mind adding documentation on how to run your own cheat.sh server. Thanks.

Hardcoded absolute paths in code

Absolute path /home/igor/ is hard-coded in some places (files listed below) in the code base. I think it might be better if this was configurable through some mechanism like env vars etc. (Not sure if it's already possible. Did not thoroughly look into the code)

  • globals.py
  • get_answer.py
  • panela/panela_colors.py
  • adapter_learnxiny.py

Vim plugin

Hello,

I just discovered cheat.sh and it is brilliant !

However the Readme does mention a Emacs mode but no vimscript and indeed I didn't found one, thus I wrote one. It is quite basic, but here it is : https://github.com/dbeniamine/cheat.sh-vim

bests,

David

Include content as meta data text representation

By having a text representation inside the meta description tag on the html header we will enable clients like telegram that leverage that info to create link previews to give more info to the users at a glance.

In Vim 7.4: paste option not working showing function errors.

I am using cht.sh in vim. I can easily search for queries and it displays in pager but when I try to paste the answer vim throws error. ( I have tried all 3 paste methods (Kp, KP and KC) nothing works

Error detected while processing function cheat#navigate:
line 58:
Zero count: d0
Sending query : "python/lxml+install+error" to https://cht.sh this may take some time
Error detected while processing function cheat#navigate..108_handleRequest:
line 31:
E117: Unknown function: job_start
E15: Invalid expression: job_start(curl, {"callback": "cheat#handleRequestOutput", "close_cb": "cheat#printAnswer"})
Press ENTER or type command to continue

Please don’t color the text by default…

  • People have their own preference for text color, please don’t force it…
  • I know ?T exists, but to use it I have to quote the URI, which is annoying.
  • The color chosen here could be unfriendly to light theme users.

Interpreting markdown

Hello, is possible to add support for markdown language? For example, when i looking for: vim hash i have answer with:

    " 1. First, go to the first line you want to comment, press
" <kbd>Ctrl</kbd><kbd>V</kbd>. This will put the editor in the VISUAL
" BLOCK mode.

Is possible to interpreting this markdown?

JSON output from site?

I feel like I must be missing something, but I can't find any mention of it: Is there no way to get data in JSON or another structured format from the site? It would make it much easier to cleanly present individual entries in clients.

cht.sh script dependency on xsel not supported in MacOS

cht.sh shell script on MacOS High Sierra (sorry no access older revs) throws message:

$ cht.sh --shell go
DEPENDENCY: please install "xsel" for "copy"
type 'help' for the cht.sh shell help

Suggest support pbcopy in place of xsel for MacOS

Python lib for making calls

If there was a python lib for this, it could be used within the python shell in my ide (PyCharm), or probably any other decent ide, with little or no special plugins needed. Secondarily, a windows command option would be helpful since the bash script nor curl works with windows without something like cywin. (and please no windows bashing, I prefer Linux as well, but you work with what you are given at many jobs).

Returning HTML not raw text.

Am I missing something?

bash-3.2$ curl cheat.sh/tar
... snip ...
<a href="https://twitter.com/igor_chubin" class="twitter-follow-button" data-show-count="false" data-button="grey">Follow @igor_chubin</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

<!-- Place this tag where you want the button to render. -->
<a aria-label="Star chubin/wttr.in on GitHub" data-count-aria-label="# stargazers on GitHub" data-count-api="/repos/chubin/cheat.sh#stargazers_count" data-count-href="/chubin/cheat.sh/stargazers" data-icon="octicon-star" href="https://github.com/chubin/cheat.sh" class="github-button">cheat.sh</a>
<!-- Place this tag where you want the button to render. --><a aria-label="Star chrisallenlane/cheat on GitHub" data-count-aria-label="# stargazers on GitHub" data-count-api="/repos/chrisallenlane/cheat#stargazers_count" data-count-href="/chrisallenlane/cheat/stargazers" data-icon="octicon-star" href="https://github.com/chrisallenlane/cheat"  class="github-button">cheat</a>
<!-- Place this tag right after the last button or just before your close body tag. -->
<script async defer id="github-bjs" src="https://buttons.github.io/buttons.js"></script>
</body>
</html>

Returns HTML instead of plain-text

On MacOS curl cht.sh returns normal HTML page for me instead of a plain text version of the cheatsheet, however curl -q cht.sh works fine.

Some languages reported as unknown even though they're suggested

Observe:

  temporal@galactica~> curl cht.sh/lisp
  Unknown topic.
  Do you mean one of these topics may be?
  
      * lisp/ 100
      * elisp/ 89
      * alias 67

Changing the URL to cht.sh/alias correctly gives a list of examples, while lisp and elisp are always reported as unknown. My guess is, something somewhere is storing those tokens with forward slash in the name, whereas the HTTP handling code strips it out from request.

yay

Presents package selection menu

yay [Search Term]

Prints system statistics

yay -Ps

Prints update list

yay -Pu

Cleans unneeded dependencies

yay -Yc

Downloads PKGBUILD from ABS or AUR

yay -G

Generates development package DB used for devel updates.

yay -Y --gendb

Normal update but also check for development package updates and uses PKGBUILD modification time and not version to determine update

yay -Syu --devel --timeupdate

INSTALATION

git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

How to get original url form cht.sh cli?

Hello,
I always find myself wanting to add more to many of the sheets, specially the unix commands. In the readme it says one way to do that is find the url and use the browser. I'm using the cli cht.sh, wondering how to find the url of the specific sheet I'm looking at?

Thanks.

copy not working

Ubuntu 18.04
xsel 1.2.0

First of all I don't know if is a xsel or cht.sh client problem.

Shell mode:

$ cht.sh --shell
cht.sh> cd python
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> copy
copy: 4 lines copied to the selection

The output says it was copied.
I try to paste (ctrl + v) it somewhere and I realized it was not on the clipboard.

But if I run the xsel command it shows the output:

$ xsel 

#  python - How do you append to a file?

with open("test.txt", "a") as myfile:
    myfile.write("appended text")

I can reproduce something like:

$ cat /etc/hosts | xsel --clipboard

And this works with either ctrl + v or the xsel command.

Invalid section

hi, my english is not good, and i hope you can understand what i want to say:
image
this is my raspberry pi displayed, but i expect it should be this :
image
or
image
it seems something is wrong with 'cd' command in my cht.sh

Offline usage

Task

Hi, how i may use cheat.sh offline, some of my servers don`t have access to the enternet, but i want to use cheat.sh)

Details

Support https

Would be nice if the site was available via https as well.

cd section fails in shell mode, returns no valid sections

On macOS High Sierra 10.13.1

Cannot use cd command to change my context for queries. Queries work normally, and I can run /:context QUERY normally.

Steps to repro

  1. Install script locally, setup permissions
$ curl https://cht.sh/:cht.sh > /usr/local/bin/cht.sh
$ chmod +x /usr/local/bin/cht.sh
  1. install rlwrap for shellmode
$ brew install rlwrap
  1. launch shell mode
cht.sh --shell
  1. attempt to cd into any section/context
cht.sh> cd go
Invalid section: go
Valid sections:
cht.sh> cd csharp
Invalid section: csharp
Valid sections:
cht.sh> cd arduino
Invalid section: arduino
Valid sections:

Unhighlighted search output differs in format from highlighted search output

I'm not sure if this is intentional or not, but I thought it worth a mention just in case...

When doing a search, with terminal highlighting on (the default), the output looks something like this:

screen shot 2017-06-02 at 16 24 46

With terminal highlighting turned off ("?T" added to the URL), the output appears a little mangled in places. The initial [ in the [] that would normally appear to wrap a topic is missing, and subsequent topics appear to be missing end-of-lines before the following text. For example:

screen shot 2017-06-02 at 16 25 02

I'd suggest that this makes for a slightly less readable output when using unhighlighted output, and potentially harder-to-parse/markup output when using unhighlighted output to feed another process.

Support for running on Python 3

flake8 testing of https://github.com/chubin/cheat.sh on Python 3.6.3

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./bin/srv.py:123:13: E999 SyntaxError: invalid syntax
    print url
            ^
./lib/adapter_learnxiny.py:32:18: E999 SyntaxError: invalid syntax
        print self.prefix, self._topics_list
                 ^
./lib/beautifier.py:240:23: E999 SyntaxError: invalid syntax
    print unindent_code
                      ^
./lib/get_answer.py:276:29: E999 SyntaxError: invalid syntax
        print "query_text = ", query_text
                            ^
./lib/globals.py:32:18: E999 SyntaxError: invalid syntax
        print text
                 ^
./lib/panela/panela_colors.py:365:44: F821 undefined name 'basestring'
        if color and not isinstance(color, basestring):
                                           ^
./lib/panela/panela_colors.py:370:54: F821 undefined name 'basestring'
        if background and not isinstance(background, basestring):
                                                     ^
5     E999 SyntaxError: invalid syntax
2     F821 undefined name 'basestring'
7

How did you make the gif for cheat.sh?

I am curious, how did you make the gif for cheat.sh?

what tool was it

I downloaded it and its only 621kb in size for a gif that seems to be over a minute long

I would love to know

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.