From e6b7a3ac7d4829504c9ad41f1c2934291cb15a7e Mon Sep 17 00:00:00 2001 From: Julien Tremblay McLellan Date: Thu, 28 Mar 2019 10:21:05 -0400 Subject: [PATCH 01/23] Ran doctoc to generate a table of contents (toc) https://github.com/thlorenz/doctoc The documentation was so nice, I couldn't help but adding a toc. --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index f6cd5b2..690be99 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,37 @@ + + +**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* + +- [Features](#features) +- [Contents](#contents) +- [Usage](#usage) +- [Command line client, cht.sh](#command-line-client-chtsh) + - [Installation](#installation) + - [Client usage](#client-usage) + - [Tab completion](#tab-completion) + - [Bash Tab completion](#bash-tab-completion) + - [ZSH Tab completion](#zsh-tab-completion) + - [Stealth mode](#stealth-mode) + - [Windows command line client](#windows-command-line-client) +- [Self-Hosting](#self-hosting) + - [Docker](#docker) +- [Editors integration](#editors-integration) + - [Vim](#vim) + - [Emacs](#emacs) + - [Visual Studio Code](#visual-studio-code) + - [Sublime](#sublime) + - [IntelliJ IDEA](#intellij-idea) +- [Special pages](#special-pages) +- [Search](#search) +- [Programming languages cheat sheets](#programming-languages-cheat-sheets) +- [Cheat sheets sources](#cheat-sheets-sources) +- [How to contribute](#how-to-contribute) + - [How to edit a cheat sheet](#how-to-edit-a-cheat-sheet) + - [How to add a cheat sheet](#how-to-add-a-cheat-sheet) + - [How to add a cheat sheet repository](#how-to-add-a-cheat-sheet-repository) + + + ![cheat.sh logo](http://cheat.sh/files/big-logo-v2-fixed.png) From 6d619cccef2eeaab689ce0adac3dc839a8efd26e Mon Sep 17 00:00:00 2001 From: Antony Kellermann Date: Thu, 21 Jan 2021 18:24:15 -0500 Subject: [PATCH 02/23] Fix some unescaped shell colors. --- share/cht.sh.txt | 2 +- tests/results/8 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index bebc1af..f9ab95c 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -692,7 +692,7 @@ cmd_stealth() { past=$current current_text="$(echo $current | tr -c '[a-zA-Z0-9]' ' ')" if [ "$(echo "$current_text" | wc -w)" -gt "$STEALTH_MAX_SELECTION_LENGTH" ]; then - echo "\033[0;31mstealth:\033[0m selection length is longer than $STEALTH_MAX_SELECTION_LENGTH words; ignoring" + printf "\033[0;31mstealth:\033[0m selection length is longer than $STEALTH_MAX_SELECTION_LENGTH words; ignoring\n" continue else printf "\n\033[0;31mstealth: \033[7m $current_text\033[0m\n" diff --git a/tests/results/8 b/tests/results/8 index bebc1af..f9ab95c 100644 --- a/tests/results/8 +++ b/tests/results/8 @@ -692,7 +692,7 @@ cmd_stealth() { past=$current current_text="$(echo $current | tr -c '[a-zA-Z0-9]' ' ')" if [ "$(echo "$current_text" | wc -w)" -gt "$STEALTH_MAX_SELECTION_LENGTH" ]; then - echo "\033[0;31mstealth:\033[0m selection length is longer than $STEALTH_MAX_SELECTION_LENGTH words; ignoring" + printf "\033[0;31mstealth:\033[0m selection length is longer than $STEALTH_MAX_SELECTION_LENGTH words; ignoring\n" continue else printf "\n\033[0;31mstealth: \033[7m $current_text\033[0m\n" From 4428ad47b5744a2aa606df1afb22e5266d3bda1c Mon Sep 17 00:00:00 2001 From: Alex Balgavy Date: Tue, 16 Feb 2021 15:56:37 +0100 Subject: [PATCH 03/23] Help text: remove outdated info, fix spelling Many more languages are supported than listed in the help file. --- share/help.txt | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/share/help.txt b/share/help.txt index 059a0c9..e2710a4 100644 --- a/share/help.txt +++ b/share/help.txt @@ -1,7 +1,7 @@ Usage: - - $ curl cheat.sh/TOPIC show cheat sheet on the TOPIC - $ curl cheat.sh/TOPIC/SUB show cheat sheet on the SUB topic in TOPIC + + $ curl cheat.sh/TOPIC show cheat sheet on the TOPIC + $ curl cheat.sh/TOPIC/SUB show cheat sheet on the SUB topic in TOPIC $ curl cheat.sh/~KEYWORD search cheat sheets for KEYWORD Options: @@ -19,7 +19,7 @@ Options: Options can be combined together in this way: curl 'cheat.sh/for?qT&style=bw' - + (when using & in shell, don't forget to specify the quotes or escape & with \) Special pages: @@ -54,7 +54,7 @@ Editor integration: Search: - /~snapshot look for "snapshot" in the first level cheat sheets + /~snapshot look for "snapshot" in the first level cheat sheets /~ssh~passphrase several keywords can be combined together using ~ /scala/~closure look for "closure" in scala cheat sheets /~snapshot/r look for "snapshot" in all cheat sheets recursively @@ -71,17 +71,9 @@ List of search options: Programming languages topics: -each programming language topic has the following subptopics: +Each programming language topic has the following subtopics: hello hello world + how to start the program :learn big cheat sheet for learning language from scratch - :list list of topics + :list list of topics :random fetches a random cheat sheet belonging to the topic - -Support programming languages: - - go - scala - rust - python - php From 5291d3a225a09a1e06ee6c663367f874dbfc5ee9 Mon Sep 17 00:00:00 2001 From: Alex Balgavy Date: Tue, 16 Feb 2021 16:19:42 +0100 Subject: [PATCH 04/23] Fix test --- tests/results/7 | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/results/7 b/tests/results/7 index 059a0c9..e2710a4 100644 --- a/tests/results/7 +++ b/tests/results/7 @@ -1,7 +1,7 @@ Usage: - - $ curl cheat.sh/TOPIC show cheat sheet on the TOPIC - $ curl cheat.sh/TOPIC/SUB show cheat sheet on the SUB topic in TOPIC + + $ curl cheat.sh/TOPIC show cheat sheet on the TOPIC + $ curl cheat.sh/TOPIC/SUB show cheat sheet on the SUB topic in TOPIC $ curl cheat.sh/~KEYWORD search cheat sheets for KEYWORD Options: @@ -19,7 +19,7 @@ Options: Options can be combined together in this way: curl 'cheat.sh/for?qT&style=bw' - + (when using & in shell, don't forget to specify the quotes or escape & with \) Special pages: @@ -54,7 +54,7 @@ Editor integration: Search: - /~snapshot look for "snapshot" in the first level cheat sheets + /~snapshot look for "snapshot" in the first level cheat sheets /~ssh~passphrase several keywords can be combined together using ~ /scala/~closure look for "closure" in scala cheat sheets /~snapshot/r look for "snapshot" in all cheat sheets recursively @@ -71,17 +71,9 @@ List of search options: Programming languages topics: -each programming language topic has the following subptopics: +Each programming language topic has the following subtopics: hello hello world + how to start the program :learn big cheat sheet for learning language from scratch - :list list of topics + :list list of topics :random fetches a random cheat sheet belonging to the topic - -Support programming languages: - - go - scala - rust - python - php From 926ad466f16400e9188b444077511f5881b54ac1 Mon Sep 17 00:00:00 2001 From: Michael Floering Date: Tue, 16 Feb 2021 12:23:01 -0800 Subject: [PATCH 05/23] README - small changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add link to jump to installation section - Add link to jump to installing tab completion. Named this link "auto-complete" so that "auto" and "complete" (ending with an -e rather than -ion) would both show up when grepped/ ⌘+F Why: - Less intimidating to newcomers — I've just observed that friends/colleagues adopt tldr rather than cheat.sh soley because they didn't see the "get started" stuff up top. So they missed it. - Faster to "just install it" when you know you're going to do that anyways. i.e. from a friend recommending. or on a new machine. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 652906b..51448e4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ What features should it have? * **Tutoring** — It should help you to learn the subject. * **Inconspicuous** — It should be possible to use it completely unnoticed. -Such a thing exists. +Such a thing exists! It's easy to [install](#installation) and there's even [auto-complete](#tab-completion). ## Features From 815df01c7d9c43681ea089095dbea845c59dbc5d Mon Sep 17 00:00:00 2001 From: Michael Floering Date: Tue, 16 Feb 2021 12:31:52 -0800 Subject: [PATCH 06/23] README - small changes - add some horizontal-rules Helps with visual scannability when scrolling down the page --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 51448e4..36c4ff5 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,8 @@ Try your own queries. Follow these rules: 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 @@ -342,6 +344,8 @@ To activate tab completion support for `cht.sh`, add the `:zsh` script to the *f $ # 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. @@ -442,6 +446,8 @@ You can also use [`scoop`](https://github.com/lukesampson/scoop) command-line in scoop install cht ``` +---- + ## Self-Hosting ### Docker From 09811e64c6cb31ca27885d32a8e03249531d1a77 Mon Sep 17 00:00:00 2001 From: Michael Floering Date: Tue, 16 Feb 2021 12:35:10 -0800 Subject: [PATCH 07/23] README - small changes - for those newer to sh This is something we take for granted but newcomers to sh, Linux, and so on. --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 36c4ff5..246c891 100644 --- a/README.md +++ b/README.md @@ -205,9 +205,10 @@ has several useful features compared to querying the service directly with `curl To install the client: ``` - mkdir -p ~/bin/ - curl https://cht.sh/:cht.sh > ~/bin/cht.sh - chmod +x ~/bin/cht.sh + 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): From 45f88f30755f3d60222ffab2cbdd3ed98ca326a8 Mon Sep 17 00:00:00 2001 From: bl-ue <54780737+bl-ue@users.noreply.github.com> Date: Sat, 27 Feb 2021 16:13:33 -0500 Subject: [PATCH 08/23] Use live badge for source repos' users/stars Also updates Stackoverflow user count from 9m to 14m. See https://stackexchange.com/leagues/1/alltime/stackoverflow --- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 246c891..edbf09e 100644 --- a/README.md +++ b/README.md @@ -822,13 +822,16 @@ all over the world |Cheat sheets |Repository | Users | Creation Date | |-----------------------|------------------------------------------------------|------------|---------------| -|UNIX/Linux, programming|[cheat.sheets](https://github.com/chubin/cheat.sheets)| 38/223 | May 1, 2017 | -|UNIX/Linux commands |[tldr-pages/tldr](https://github.com/tldr-pages/tldr) | 760/23158 | Dec 8, 2013 | -|UNIX/Linux commands |[chrisallenlane/cheat](https://github.com/chrisallenlane/cheat)|131/5240|Jul 28, 2013| -|Programming languages |[adambard/learnxinyminutes-docs](https://github.com/adambard/learnxinyminutes-docs)|1246/6748|Jun 23, 2013| -|Go |[a8m/go-lang-cheat-sheet](https://github.com/a8m/go-lang-cheat-sheet)|31/4039|Feb 9, 2014| -|Perl |[pkrumnis/perl1line.txt](https://github.com/pkrumins/perl1line.txt)|5/190|Nov 4, 2011| -|Programming languages |[StackOverflow](https://stackoverflow.com)|9M |Sep 15, 2008| +|UNIX/Linux, programming|[cheat.sheets](https://github.com/chubin/cheat.sheets)|![](https://img.shields.io/github/contributors-anon/chubin/cheat.sheets) ![](https://img.shields.io/github/stars/chubin/cheat.sheets)|May 1, 2017| +|UNIX/Linux commands |[tldr-pages/tldr](https://github.com/tldr-pages/tldr) |![](https://img.shields.io/github/contributors-anon/tldr-pages/tldr) ![](https://img.shields.io/github/stars/tldr-pages/tldr)|Dec 8, 2013| +|UNIX/Linux commands |[chrisallenlane/cheat](https://github.com/chrisallenlane/cheat)|![](https://img.shields.io/github/contributors-anon/chrisallenlane/cheat) ![](https://img.shields.io/github/stars/chrisallenlane/cheat)|Jul 28, 2013| +|Programming languages |[adambard/learnxinyminutes-docs](https://github.com/adambard/learnxinyminutes-docs)|![](https://img.shields.io/github/contributors-anon/adambard/learnxinyminutes-docs) ![](https://img.shields.io/github/stars/adambard/learnxinyminutes-docs)|Jun 23, 2013| +|Go |[a8m/go-lang-cheat-sheet](https://github.com/a8m/go-lang-cheat-sheet)|![](https://img.shields.io/github/contributors-anon/a8m/go-lang-cheat-sheet) ![](https://img.shields.io/github/stars/a8m/go-lang-cheat-sheet)|Feb 9, 2014| +|Perl |[pkrumnis/perl1line.txt](https://github.com/pkrumins/perl1line.txt)|![](https://img.shields.io/github/contributors-anon/pkrumins/perl1line.txt) ![](https://img.shields.io/github/stars/pkrumins/perl1line.txt)|Nov 4, 2011| +|Programming languages |[StackOverflow](https://stackoverflow.com)|[14M](https://stackexchange.com/leagues/1/alltime/stackoverflow)|Sep 15, 2008| + +[cheat.sheets users]: https://img.shields.io/github/contributors-anon/chubin/cheat.sheets +[cheat.sheets stars]: https://img.shields.io/github/stars/chubin/cheat.sheets Pie diagram reflecting cheat sheets sources distribution (by number of cheat sheets on cheat.sh originating from a repository): From e8807ae3e48874545a92e885d2a23522fc3bf744 Mon Sep 17 00:00:00 2001 From: bl-ue <54780737+bl-ue@users.noreply.github.com> Date: Sat, 27 Feb 2021 18:05:19 -0500 Subject: [PATCH 09/23] Remove unused links --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index edbf09e..61f3730 100644 --- a/README.md +++ b/README.md @@ -830,9 +830,6 @@ all over the world |Perl |[pkrumnis/perl1line.txt](https://github.com/pkrumins/perl1line.txt)|![](https://img.shields.io/github/contributors-anon/pkrumins/perl1line.txt) ![](https://img.shields.io/github/stars/pkrumins/perl1line.txt)|Nov 4, 2011| |Programming languages |[StackOverflow](https://stackoverflow.com)|[14M](https://stackexchange.com/leagues/1/alltime/stackoverflow)|Sep 15, 2008| -[cheat.sheets users]: https://img.shields.io/github/contributors-anon/chubin/cheat.sheets -[cheat.sheets stars]: https://img.shields.io/github/stars/chubin/cheat.sheets - Pie diagram reflecting cheat sheets sources distribution (by number of cheat sheets on cheat.sh originating from a repository): ![cheat.sh cheat sheets repositories](http://cheat.sh/files/stat-2017-06-05.png) From dee6b24b25ecdf07d995c47455db3bf43adc3621 Mon Sep 17 00:00:00 2001 From: bl-ue <54780737+bl-ue@users.noreply.github.com> Date: Sun, 28 Feb 2021 12:22:50 -0500 Subject: [PATCH 10/23] Use icons for source repos' users/stars See https://github.com/chubin/cheat.sh/pull/285#issuecomment-787416248 --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 61f3730..d915dd3 100644 --- a/README.md +++ b/README.md @@ -820,15 +820,15 @@ and information sources, maintained by thousands of users, developers and author all over the world (in the *Users* column number of contributors/number of stars is shown): -|Cheat sheets |Repository | Users | Creation Date | -|-----------------------|------------------------------------------------------|------------|---------------| -|UNIX/Linux, programming|[cheat.sheets](https://github.com/chubin/cheat.sheets)|![](https://img.shields.io/github/contributors-anon/chubin/cheat.sheets) ![](https://img.shields.io/github/stars/chubin/cheat.sheets)|May 1, 2017| -|UNIX/Linux commands |[tldr-pages/tldr](https://github.com/tldr-pages/tldr) |![](https://img.shields.io/github/contributors-anon/tldr-pages/tldr) ![](https://img.shields.io/github/stars/tldr-pages/tldr)|Dec 8, 2013| -|UNIX/Linux commands |[chrisallenlane/cheat](https://github.com/chrisallenlane/cheat)|![](https://img.shields.io/github/contributors-anon/chrisallenlane/cheat) ![](https://img.shields.io/github/stars/chrisallenlane/cheat)|Jul 28, 2013| -|Programming languages |[adambard/learnxinyminutes-docs](https://github.com/adambard/learnxinyminutes-docs)|![](https://img.shields.io/github/contributors-anon/adambard/learnxinyminutes-docs) ![](https://img.shields.io/github/stars/adambard/learnxinyminutes-docs)|Jun 23, 2013| -|Go |[a8m/go-lang-cheat-sheet](https://github.com/a8m/go-lang-cheat-sheet)|![](https://img.shields.io/github/contributors-anon/a8m/go-lang-cheat-sheet) ![](https://img.shields.io/github/stars/a8m/go-lang-cheat-sheet)|Feb 9, 2014| -|Perl |[pkrumnis/perl1line.txt](https://github.com/pkrumins/perl1line.txt)|![](https://img.shields.io/github/contributors-anon/pkrumins/perl1line.txt) ![](https://img.shields.io/github/stars/pkrumins/perl1line.txt)|Nov 4, 2011| -|Programming languages |[StackOverflow](https://stackoverflow.com)|[14M](https://stackexchange.com/leagues/1/alltime/stackoverflow)|Sep 15, 2008| +|Cheat sheets |Repository |Users |Stars |Creation Date| +|-----------------------|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|-------------| +|UNIX/Linux, programming|[cheat.sheets](https://github.com/chubin/cheat.sheets) |![](https://img.shields.io/github/contributors-anon/chubin/cheat.sheets?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/chubin/cheat.sheets?label=%E2%AD%90&labelColor=white) |May 1, 2017 | +|UNIX/Linux commands |[tldr-pages/tldr](https://github.com/tldr-pages/tldr) |![](https://img.shields.io/github/stars/tldr-pages/tldr?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/tldr-pages/tldr?label=%E2%AD%90&labelColor=white) |Dec 8, 2013 | +|UNIX/Linux commands |[chrisallenlane/cheat](https://github.com/chrisallenlane/cheat) |![](https://img.shields.io/github/contributors-anon/chrisallenlane/cheat?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/chrisallenlane/cheat?label=%E2%AD%90&labelColor=white) |Jul 28, 2013 | +|Programming languages |[adambard/learnxinyminutes-docs](https://github.com/adambard/learnxinyminutes-docs) |![](https://img.shields.io/github/contributors-anon/adambard/learnxinyminutes-docs?label=%F0%9F%91%A5&labelColor=white)|![](https://img.shields.io/github/stars/adambard/learnxinyminutes-docs?label=%E2%AD%90&labelColor=white)|Jun 23, 2013 | +|Go |[a8m/go-lang-cheat-sheet](https://github.com/a8m/go-lang-cheat-sheet) |![](https://img.shields.io/github/contributors-anon/a8m/go-lang-cheat-sheet?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/a8m/go-lang-cheat-sheet?label=%E2%AD%90&labelColor=white) |Feb 9, 2014 | +|Perl |[pkrumnis/perl1line.txt](https://github.com/pkrumins/perl1line.txt) |![](https://img.shields.io/github/contributors-anon/pkrumins/perl1line.txt?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/pkrumins/perl1line.txt?label=%E2%AD%90&labelColor=white) |Nov 4, 2011 | +|Programming languages |[StackOverflow](https://stackoverflow.com) |[14M](https://stackexchange.com/leagues/1/alltime/stackoverflow) |N/A |Sep 15, 2008 | Pie diagram reflecting cheat sheets sources distribution (by number of cheat sheets on cheat.sh originating from a repository): From 249e7cee4edc9919075b5fa5b089c647ae18f11b Mon Sep 17 00:00:00 2001 From: bl-ue <54780737+bl-ue@users.noreply.github.com> Date: Sun, 28 Feb 2021 12:26:57 -0500 Subject: [PATCH 11/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d915dd3..5eabecb 100644 --- a/README.md +++ b/README.md @@ -823,7 +823,7 @@ all over the world |Cheat sheets |Repository |Users |Stars |Creation Date| |-----------------------|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|-------------| |UNIX/Linux, programming|[cheat.sheets](https://github.com/chubin/cheat.sheets) |![](https://img.shields.io/github/contributors-anon/chubin/cheat.sheets?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/chubin/cheat.sheets?label=%E2%AD%90&labelColor=white) |May 1, 2017 | -|UNIX/Linux commands |[tldr-pages/tldr](https://github.com/tldr-pages/tldr) |![](https://img.shields.io/github/stars/tldr-pages/tldr?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/tldr-pages/tldr?label=%E2%AD%90&labelColor=white) |Dec 8, 2013 | +|UNIX/Linux commands |[tldr-pages/tldr](https://github.com/tldr-pages/tldr) |![](https://img.shields.io/github/contributors-anon/tldr-pages/tldr?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/tldr-pages/tldr?label=%E2%AD%90&labelColor=white) |Dec 8, 2013 | |UNIX/Linux commands |[chrisallenlane/cheat](https://github.com/chrisallenlane/cheat) |![](https://img.shields.io/github/contributors-anon/chrisallenlane/cheat?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/chrisallenlane/cheat?label=%E2%AD%90&labelColor=white) |Jul 28, 2013 | |Programming languages |[adambard/learnxinyminutes-docs](https://github.com/adambard/learnxinyminutes-docs) |![](https://img.shields.io/github/contributors-anon/adambard/learnxinyminutes-docs?label=%F0%9F%91%A5&labelColor=white)|![](https://img.shields.io/github/stars/adambard/learnxinyminutes-docs?label=%E2%AD%90&labelColor=white)|Jun 23, 2013 | |Go |[a8m/go-lang-cheat-sheet](https://github.com/a8m/go-lang-cheat-sheet) |![](https://img.shields.io/github/contributors-anon/a8m/go-lang-cheat-sheet?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/a8m/go-lang-cheat-sheet?label=%E2%AD%90&labelColor=white) |Feb 9, 2014 | From 42097e2c9d981ab8a98b257be5ab85e7ce14b15b Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Fri, 5 Mar 2021 09:54:19 +0300 Subject: [PATCH 12/23] Fix w3c validator error about self-closing `
` --- lib/frontend/html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/frontend/html.py b/lib/frontend/html.py index a130e69..43469d3 100644 --- a/lib/frontend/html.py +++ b/lib/frontend/html.py @@ -96,7 +96,7 @@ def _render_html(query, result, editable, repository_button, topics_list, reques curl_line = "$ curl cheat.sh/" if query == ':firstpage': query = "" - form_html = ('' + form_html = ('' '%s%s' ' Date: Thu, 18 Mar 2021 18:11:23 +0800 Subject: [PATCH 13/23] Fix syntax highlight in README - Specific bash in some code blocks - Specific zsh in zshrc config - Fix unclosed `code` markup --- README.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 61f3730..14cdd99 100644 --- a/README.md +++ b/README.md @@ -204,18 +204,18 @@ has several useful features compared to querying the service directly with `curl 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" +```bash +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 https://cht.sh/:cht.sh | sudo tee /usr/local/bin/cht.sh - chmod +x /usr/local/bin/cht.sh +```bash +curl https://cht.sh/:cht.sh | sudo tee /usr/local/bin/cht.sh +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` @@ -303,13 +303,13 @@ 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: -``` +```bash CHTSH_QUERY_OPTIONS="T" ``` Or if you want to use a special syntax highlighting theme: -``` +```bash CHTSH_QUERY_OPTIONS="style=native" ``` @@ -317,7 +317,7 @@ CHTSH_QUERY_OPTIONS="style=native" Other cht.sh configuration parameters: -``` +```bash CHTSH_CURL_OPTIONS="-A curl" # curl options used for cht.sh queries CHTSH_URL=https://cht.sh # URL of the cheat.sh server ``` @@ -329,20 +329,20 @@ CHTSH_URL=https://cht.sh # URL of the cheat.sh server 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 +```bash + 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 +```zsh + curl https://cheat.sh/:zsh > ~/.zsh.d/_cht + echo 'fpath=(~/.zsh.d/ $fpath)' >> ~/.zshrc + # Open a new shell to load the plugin ``` ---- @@ -536,7 +536,7 @@ In this example, several Vim plugins are used: * [scrooloose/syntastic](https://github.com/vim-syntastic/syntastic) — Syntax checking plugin * [cheat.sh-vim](https://github.com/dbeniamine/cheat.sh-vim) — Vim support -Syntastic shows warnings and errors (found by code analysis tools: `jshint`, `merlin`, `pylint`, `shellcheckt etc.), +Syntastic shows warnings and errors (found by code analysis tools: `jshint`, `merlin`, `pylint`, `shellcheckt` etc.), and `cheat.sh-vim` shows you explanations for the errors and warnings and answers on programming languages queries written in the editor. From 6692850495c6dbc3a80e12f0606a36d663b6d3fc Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 18 Mar 2021 19:24:57 +0800 Subject: [PATCH 14/23] Fix typo in README Co-authored-by: Anatoli Babenia --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 14cdd99..7a51594 100644 --- a/README.md +++ b/README.md @@ -536,7 +536,7 @@ In this example, several Vim plugins are used: * [scrooloose/syntastic](https://github.com/vim-syntastic/syntastic) — Syntax checking plugin * [cheat.sh-vim](https://github.com/dbeniamine/cheat.sh-vim) — Vim support -Syntastic shows warnings and errors (found by code analysis tools: `jshint`, `merlin`, `pylint`, `shellcheckt` etc.), +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. From 1d9a7bd1c1e384403e0167faa68d67d16f6fc11c Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Tue, 6 Apr 2021 08:12:18 +0200 Subject: [PATCH 15/23] Users/Contributors --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ebae76..0f75447 100644 --- a/README.md +++ b/README.md @@ -820,7 +820,7 @@ and information sources, maintained by thousands of users, developers and author all over the world (in the *Users* column number of contributors/number of stars is shown): -|Cheat sheets |Repository |Users |Stars |Creation Date| +|Cheat sheets |Repository |C/U* |Stars |Creation Date| |-----------------------|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|-------------| |UNIX/Linux, programming|[cheat.sheets](https://github.com/chubin/cheat.sheets) |![](https://img.shields.io/github/contributors-anon/chubin/cheat.sheets?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/chubin/cheat.sheets?label=%E2%AD%90&labelColor=white) |May 1, 2017 | |UNIX/Linux commands |[tldr-pages/tldr](https://github.com/tldr-pages/tldr) |![](https://img.shields.io/github/contributors-anon/tldr-pages/tldr?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/tldr-pages/tldr?label=%E2%AD%90&labelColor=white) |Dec 8, 2013 | @@ -830,6 +830,8 @@ all over the world |Perl |[pkrumnis/perl1line.txt](https://github.com/pkrumins/perl1line.txt) |![](https://img.shields.io/github/contributors-anon/pkrumins/perl1line.txt?label=%F0%9F%91%A5&labelColor=white) |![](https://img.shields.io/github/stars/pkrumins/perl1line.txt?label=%E2%AD%90&labelColor=white) |Nov 4, 2011 | |Programming languages |[StackOverflow](https://stackoverflow.com) |[14M](https://stackexchange.com/leagues/1/alltime/stackoverflow) |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](http://cheat.sh/files/stat-2017-06-05.png) From 8af942e51616a6ac5e5cd50c693854f1af78e5a6 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Thu, 22 Apr 2021 17:07:31 +0200 Subject: [PATCH 16/23] Update TOC --- README.md | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 8ccc3a0..4af6d78 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,3 @@ - - -**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* - -- [Features](#features) -- [Contents](#contents) -- [Usage](#usage) -- [Command line client, cht.sh](#command-line-client-chtsh) - - [Installation](#installation) - - [Client usage](#client-usage) - - [Tab completion](#tab-completion) - - [Bash Tab completion](#bash-tab-completion) - - [ZSH Tab completion](#zsh-tab-completion) - - [Stealth mode](#stealth-mode) - - [Windows command line client](#windows-command-line-client) -- [Self-Hosting](#self-hosting) - - [Docker](#docker) -- [Editors integration](#editors-integration) - - [Vim](#vim) - - [Emacs](#emacs) - - [Visual Studio Code](#visual-studio-code) - - [Sublime](#sublime) - - [IntelliJ IDEA](#intellij-idea) -- [Special pages](#special-pages) -- [Search](#search) -- [Programming languages cheat sheets](#programming-languages-cheat-sheets) -- [Cheat sheets sources](#cheat-sheets-sources) -- [How to contribute](#how-to-contribute) - - [How to edit a cheat sheet](#how-to-edit-a-cheat-sheet) - - [How to add a cheat sheet](#how-to-add-a-cheat-sheet) - - [How to add a cheat sheet repository](#how-to-add-a-cheat-sheet-repository) - - ![cheat.sh logo](http://cheat.sh/files/big-logo-v2-fixed.png) @@ -77,7 +44,10 @@ Such a thing exists! It's easy to [install](#installation) and there's even [aut * [Installation](#installation) * [Client usage](#client-usage) * [Tab-completion](#tab-completion) + - [Bash Tab completion](#bash-tab-completion) + - [ZSH Tab completion](#zsh-tab-completion) * [Stealth mode](#stealth-mode) + * [Windows command line client](#windows-command-line-client) * [Self-Hosting](#self-hosting) * [Docker](#docker) * [Editors integration](#editors-integration) From 348db3e7a9dea17646ed88765cb28d26ad4a40db Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Fri, 23 Apr 2021 13:39:06 +0200 Subject: [PATCH 17/23] Bump cht.sh (client) version --- share/cht.sh.txt | 4 ++-- tests/results/8 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index f9ab95c..c49ca7b 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -24,8 +24,8 @@ # count words in text counter # group elements list -__CHTSH_VERSION=0.0.1 -__CHTSH_DATETIME="2020-08-05 09:30:30 +0200" +__CHTSH_VERSION=0.0.2 +__CHTSH_DATETIME="2021-04-23 09:30:30 +0200" # cht.sh configuration loading # diff --git a/tests/results/8 b/tests/results/8 index f9ab95c..c49ca7b 100644 --- a/tests/results/8 +++ b/tests/results/8 @@ -24,8 +24,8 @@ # count words in text counter # group elements list -__CHTSH_VERSION=0.0.1 -__CHTSH_DATETIME="2020-08-05 09:30:30 +0200" +__CHTSH_VERSION=0.0.2 +__CHTSH_DATETIME="2021-04-23 09:30:30 +0200" # cht.sh configuration loading # From b071e17eccbf599af4dff42fa757e453a01fed97 Mon Sep 17 00:00:00 2001 From: Scott Little Date: Fri, 23 Apr 2021 14:02:41 -0500 Subject: [PATCH 18/23] Add support for wl-copy/Wayland --- share/cht.sh.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index c49ca7b..3b7f125 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -514,7 +514,11 @@ else fi if [ "$is_macos" != yes ]; then - command -v xsel >/dev/null || echo 'DEPENDENCY: please install "xsel" for "copy"' >&2 + if [ "$XDG_SESSION_TYPE" = wayland ]; then + command -v wl-copy >/dev/null || echo 'DEPENDENCY: please install "wl-copy" for "copy"' >&2 + else + command -v xsel >/dev/null || echo 'DEPENDENCY: please install "xsel" for "copy"' >&2 + fi fi command -v rlwrap >/dev/null || { echo 'DEPENDENCY: install "rlwrap" to use cht.sh in the shell mode' >&2; exit 1; } @@ -562,7 +566,11 @@ cmd_copy() { else curl -s "${CHTSH_URL}"/"$(get_query_options "$query"?T)" > "$TMP1" if [ "$is_macos" != yes ]; then - xsel -bi < "$TMP1" + if [ "$XDG_SESSION_TYPE" = wayland ]; then + wl-copy < "$TMP1" + else + xsel -bi < "$TMP1" + fi else pbcopy < "$TMP1" fi @@ -578,7 +586,11 @@ cmd_ccopy() { else curl -s "${CHTSH_URL}"/"$(get_query_options "$query"?TQ)" > "$TMP1" if [ "$is_macos" != yes ]; then - xsel -bi < "$TMP1" + if [ "$XDG_SESSION_TYPE" = wayland ]; then + wl-copy < "$TMP1" + else + xsel -bi < "$TMP1" + fi else pbcopy < "$TMP1" fi From 064eacf513b5779f5a2f6311a71b94cb5576785e Mon Sep 17 00:00:00 2001 From: Scott Little Date: Fri, 23 Apr 2021 14:10:48 -0500 Subject: [PATCH 19/23] Add wayland support to stealth-mode --- share/cht.sh.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index 3b7f125..a4532d8 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -686,7 +686,11 @@ cmd_stealth() { if [ "$is_macos" = yes ]; then past=$(pbpaste) else - past=$(xsel -o) + if [ "$XDG_SESSION_TYPE" = wayland ]; then + past=$(xl-paste -p) + else + past=$(xsel -o) + fi fi printf "\033[0;31mstealth:\033[0m you are in the stealth mode; select any text in any window for a query\n" printf "\033[0;31mstealth:\033[0m selections longer than $STEALTH_MAX_SELECTION_LENGTH words are ignored\n" @@ -698,7 +702,11 @@ cmd_stealth() { if [ "$is_macos" = yes ]; then current=$(pbpaste) else - current=$(xsel -o) + if [ "$XDG_SESSION_TYPE" = wayland ]; then + current=$(wl-paste -p) + else + current=$(xsel -o) + fi fi if [ "$past" != "$current" ]; then past=$current From 8e789a884fec6b42c45d00b577b87c0dc61f8fb5 Mon Sep 17 00:00:00 2001 From: Scott Little Date: Fri, 23 Apr 2021 14:14:06 -0500 Subject: [PATCH 20/23] Fix typographical error --- share/cht.sh.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index a4532d8..c4520ab 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -687,7 +687,7 @@ cmd_stealth() { past=$(pbpaste) else if [ "$XDG_SESSION_TYPE" = wayland ]; then - past=$(xl-paste -p) + past=$(wl-paste -p) else past=$(xsel -o) fi From a15c9fdfa52de3b821a2aa5d8f949ca313622fb7 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sun, 25 Apr 2021 08:41:51 +0200 Subject: [PATCH 21/23] Bump cht.sh version --- share/cht.sh.txt | 4 ++-- tests/results/8 | 34 +++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index c4520ab..2333509 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -24,8 +24,8 @@ # count words in text counter # group elements list -__CHTSH_VERSION=0.0.2 -__CHTSH_DATETIME="2021-04-23 09:30:30 +0200" +__CHTSH_VERSION=0.0.3 +__CHTSH_DATETIME="2021-04-25 09:30:30 +0200" # cht.sh configuration loading # diff --git a/tests/results/8 b/tests/results/8 index c49ca7b..2333509 100644 --- a/tests/results/8 +++ b/tests/results/8 @@ -24,8 +24,8 @@ # count words in text counter # group elements list -__CHTSH_VERSION=0.0.2 -__CHTSH_DATETIME="2021-04-23 09:30:30 +0200" +__CHTSH_VERSION=0.0.3 +__CHTSH_DATETIME="2021-04-25 09:30:30 +0200" # cht.sh configuration loading # @@ -514,7 +514,11 @@ else fi if [ "$is_macos" != yes ]; then - command -v xsel >/dev/null || echo 'DEPENDENCY: please install "xsel" for "copy"' >&2 + if [ "$XDG_SESSION_TYPE" = wayland ]; then + command -v wl-copy >/dev/null || echo 'DEPENDENCY: please install "wl-copy" for "copy"' >&2 + else + command -v xsel >/dev/null || echo 'DEPENDENCY: please install "xsel" for "copy"' >&2 + fi fi command -v rlwrap >/dev/null || { echo 'DEPENDENCY: install "rlwrap" to use cht.sh in the shell mode' >&2; exit 1; } @@ -562,7 +566,11 @@ cmd_copy() { else curl -s "${CHTSH_URL}"/"$(get_query_options "$query"?T)" > "$TMP1" if [ "$is_macos" != yes ]; then - xsel -bi < "$TMP1" + if [ "$XDG_SESSION_TYPE" = wayland ]; then + wl-copy < "$TMP1" + else + xsel -bi < "$TMP1" + fi else pbcopy < "$TMP1" fi @@ -578,7 +586,11 @@ cmd_ccopy() { else curl -s "${CHTSH_URL}"/"$(get_query_options "$query"?TQ)" > "$TMP1" if [ "$is_macos" != yes ]; then - xsel -bi < "$TMP1" + if [ "$XDG_SESSION_TYPE" = wayland ]; then + wl-copy < "$TMP1" + else + xsel -bi < "$TMP1" + fi else pbcopy < "$TMP1" fi @@ -674,7 +686,11 @@ cmd_stealth() { if [ "$is_macos" = yes ]; then past=$(pbpaste) else - past=$(xsel -o) + if [ "$XDG_SESSION_TYPE" = wayland ]; then + past=$(wl-paste -p) + else + past=$(xsel -o) + fi fi printf "\033[0;31mstealth:\033[0m you are in the stealth mode; select any text in any window for a query\n" printf "\033[0;31mstealth:\033[0m selections longer than $STEALTH_MAX_SELECTION_LENGTH words are ignored\n" @@ -686,7 +702,11 @@ cmd_stealth() { if [ "$is_macos" = yes ]; then current=$(pbpaste) else - current=$(xsel -o) + if [ "$XDG_SESSION_TYPE" = wayland ]; then + current=$(wl-paste -p) + else + current=$(xsel -o) + fi fi if [ "$past" != "$current" ]; then past=$current From 74876d6d9451d2e848f9b1a10fcd674c93e9ae37 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sun, 25 Apr 2021 10:36:48 +0000 Subject: [PATCH 22/23] Call virtualenv directly (cht.sh) --- share/cht.sh.txt | 8 ++++---- tests/results/8 | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index 2333509..2f662ac 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -24,8 +24,8 @@ # count words in text counter # group elements list -__CHTSH_VERSION=0.0.3 -__CHTSH_DATETIME="2021-04-25 09:30:30 +0200" +__CHTSH_VERSION=0.0.4 +__CHTSH_DATETIME="2021-04-25 12:30:30 +0200" # cht.sh configuration loading # @@ -199,8 +199,8 @@ EOF fi _say_what_i_do Creating virtual environment - "$python" "$(command -v virtualenv)" "${virtualenv_python3_option[@]}" ve \ - || fatal Could not create virtual environment with "python2 $(command -v virtualenv) ve" + virtualenv "${virtualenv_python3_option[@]}" ve \ + || fatal "Could not create virtual environment with 'virtualenv ve'" export CHEATSH_PATH_WORKDIR=$PWD diff --git a/tests/results/8 b/tests/results/8 index 2333509..2f662ac 100644 --- a/tests/results/8 +++ b/tests/results/8 @@ -24,8 +24,8 @@ # count words in text counter # group elements list -__CHTSH_VERSION=0.0.3 -__CHTSH_DATETIME="2021-04-25 09:30:30 +0200" +__CHTSH_VERSION=0.0.4 +__CHTSH_DATETIME="2021-04-25 12:30:30 +0200" # cht.sh configuration loading # @@ -199,8 +199,8 @@ EOF fi _say_what_i_do Creating virtual environment - "$python" "$(command -v virtualenv)" "${virtualenv_python3_option[@]}" ve \ - || fatal Could not create virtual environment with "python2 $(command -v virtualenv) ve" + virtualenv "${virtualenv_python3_option[@]}" ve \ + || fatal "Could not create virtual environment with 'virtualenv ve'" export CHEATSH_PATH_WORKDIR=$PWD From 562875eda610b0322819def25f2d27af1bf9469a Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sun, 25 Apr 2021 10:37:28 +0000 Subject: [PATCH 23/23] Decode bytes to str (fetch.py) (fixes #291) --- lib/adapter/git_adapter.py | 2 +- lib/fetch.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/adapter/git_adapter.py b/lib/adapter/git_adapter.py index b8a8d29..0ce4d31 100644 --- a/lib/adapter/git_adapter.py +++ b/lib/adapter/git_adapter.py @@ -134,7 +134,7 @@ class GitRepositoryAdapter(RepositoryAdapter): #pylint: disable=abstract-meth """ local_repository_dir = cls.local_repository_location() state_filename = os.path.join(local_repository_dir, '.cached_revision') - open(state_filename, 'w').write(state) + open(state_filename, 'wb').write(state) @classmethod def get_state(cls): diff --git a/lib/fetch.py b/lib/fetch.py index 7d57fd3..df85aea 100644 --- a/lib/fetch.py +++ b/lib/fetch.py @@ -136,6 +136,7 @@ def _update_adapter(adptr): updates = [] if cmd: errorcode, output = _run_cmd(cmd) + output = output.decode("utf-8") if errorcode: _log("\nERROR:\n---\n" + output + "\n---\nCould not get list of pages to be updated: %s" % adptr) return False