1
1
mirror of https://github.com/chubin/cheat.sh.git synced 2024-11-22 01:40:48 +03:00

Compare commits

...

37 Commits

Author SHA1 Message Date
Igor Chubin
9ab558cc98 Fix keyword-based search (#323)
* Fixes directories handling in git-based repos
* Fixes a minor bug in tldr-adapter
2022-04-17 05:54:37 +00:00
Igor Chubin
60cc9faf39 Merge branch 'master' into chubin.devkeys 2021-04-25 12:19:31 +00:00
Igor Chubin
26348029c8 Add support for 'action' queries 2021-04-25 12:19:02 +00:00
Igor Chubin
48e2626c3e Merge branch 'master' into chubin.devkeys 2021-04-25 12:17:41 +00:00
Igor Chubin
562875eda6 Decode bytes to str (fetch.py) (fixes #291) 2021-04-25 10:37:28 +00:00
Igor Chubin
74876d6d94 Call virtualenv directly (cht.sh) 2021-04-25 10:36:48 +00:00
Igor Chubin
95e5b88b94
Merge pull request #293 from CodeLongAndProsper90/wayland-copy
Add Wayland support
2021-04-25 08:45:05 +02:00
Igor Chubin
a15c9fdfa5 Bump cht.sh version 2021-04-25 08:41:51 +02:00
Scott Little
8e789a884f Fix typographical error 2021-04-23 14:14:06 -05:00
Scott Little
064eacf513 Add wayland support to stealth-mode 2021-04-23 14:10:48 -05:00
Scott Little
b071e17ecc Add support for wl-copy/Wayland 2021-04-23 14:02:41 -05:00
Igor Chubin
348db3e7a9 Bump cht.sh (client) version 2021-04-23 13:39:06 +02:00
Igor Chubin
0da5cbaeef
Merge pull request #277 from aokellermann/bug/FixShEscape
Fix some unescaped shell colors
2021-04-23 13:37:39 +02:00
Igor Chubin
8af942e516
Update TOC 2021-04-22 17:07:31 +02:00
Igor Chubin
bdde91a6f4
Merge pull request #136 from julien-tremblay-mclellan/master
Ran doctoc to generate a table of contents (toc)
2021-04-22 17:01:53 +02:00
Igor Chubin
1d9a7bd1c1
Users/Contributors 2021-04-06 08:12:18 +02:00
Igor Chubin
5dff76a866
Merge pull request #286 from bl-ue/patch-1
Use icons for source repos' users/stars
2021-04-06 08:09:38 +02:00
Anatoli Babenia
83bffa587b
Merge pull request #289 from Sea-n/patch-1
Fix syntax highlight in README
2021-03-18 17:27:51 +03:00
Sean
6692850495
Fix typo in README
Co-authored-by: Anatoli Babenia <anatoli@rainforce.org>
2021-03-18 19:24:57 +08:00
Sean Wei
7655f75f26 Fix syntax highlight in README
- Specific bash in some code blocks
- Specific zsh in zshrc config
- Fix unclosed `code` markup
2021-03-18 18:11:23 +08:00
Anatoli Babenia
42097e2c9d
Fix w3c validator error about self-closing <form> 2021-03-05 09:54:19 +03:00
bl-ue
249e7cee4e
Update README.md 2021-02-28 12:26:57 -05:00
bl-ue
dee6b24b25
Use icons for source repos' users/stars
See https://github.com/chubin/cheat.sh/pull/285#issuecomment-787416248
2021-02-28 12:22:50 -05:00
Anatoli Babenia
cc88458ce3
Merge pull request #285 from bl-ue/patch-1
Use live badge for source repos' users/stars
2021-02-28 10:00:50 +03:00
bl-ue
e8807ae3e4
Remove unused links 2021-02-27 18:05:19 -05:00
bl-ue
45f88f3075
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
2021-02-27 16:13:33 -05:00
Igor Chubin
979db65059
Merge pull request #283 from hangtwenty/patch-1
README - small changes
2021-02-27 11:47:07 +01:00
Igor Chubin
7347f42ec7
Merge pull request #282 from thezeroalpha/master
Help text: remove outdated information, fix spelling
2021-02-27 11:45:02 +01:00
Michael Floering
09811e64c6
README - small changes - for those newer to sh
This is something we take for granted but newcomers to sh, Linux, and so on.
2021-02-16 12:35:10 -08:00
Michael Floering
815df01c7d
README - small changes - add some horizontal-rules
Helps with visual scannability when scrolling down the page
2021-02-16 12:31:52 -08:00
Michael Floering
926ad466f1
README - small changes
- 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.
2021-02-16 12:23:01 -08:00
Alex Balgavy
5291d3a225 Fix test 2021-02-16 16:19:42 +01:00
Alex Balgavy
4428ad47b5 Help text: remove outdated info, fix spelling
Many more languages are supported than listed in the help file.
2021-02-16 15:56:37 +01:00
Igor Chubin
01e5791769
Merge pull request #280 from ChrisLovering/Add-aiohttp-as-a-plain-text-agent
Add aiohttp as a plain text agent
2021-01-31 17:49:43 +01:00
Chris
eb67a5e0c1 Add aiohttp as a plain text agent 2021-01-31 16:09:42 +00:00
Antony Kellermann
6d619cccef Fix some unescaped shell colors. 2021-01-21 18:24:15 -05:00
Julien Tremblay McLellan
e6b7a3ac7d 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. 2019-03-28 10:21:05 -04:00
13 changed files with 154 additions and 89 deletions

View File

@ -1,4 +1,5 @@
![cheat.sh logo](http://cheat.sh/files/big-logo-v2-fixed.png)
Unified access to the best community driven cheat sheets repositories of the world.
@ -15,7 +16,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
@ -43,7 +44,10 @@ Such a thing exists.
* [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)
@ -187,6 +191,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
@ -202,17 +208,18 @@ 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
```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`
@ -300,13 +307,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"
```
@ -314,7 +321,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
```
@ -326,21 +333,23 @@ 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`:
```zsh
curl https://cheat.sh/:zsh > ~/.zsh.d/_cht
echo 'fpath=(~/.zsh.d/ $fpath)' >> ~/.zshrc
# Open a new shell to load the plugin
```
$ curl https://cheat.sh/:zsh > ~/.zsh.d/_cht
$ echo 'fpath=(~/.zsh.d/ $fpath)' >> ~/.zshrc
$ # Open a new shell to load the plugin
```
----
### Stealth mode
@ -442,6 +451,8 @@ You can also use [`scoop`](https://github.com/lukesampson/scoop) command-line in
scoop install cht
```
----
## Self-Hosting
### Docker
@ -529,7 +540,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.
@ -813,15 +824,17 @@ 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)| 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|
|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 |
|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 |
<sup>(*) C/U — contributors for GitHub repositories, Users for Stackoverflow</sup>
Pie diagram reflecting cheat sheets sources distribution (by number of cheat sheets on cheat.sh originating from a repository):

View File

@ -77,6 +77,7 @@ PLAIN_TEXT_AGENTS = [
"openbsd ftp",
"powershell",
"fetch",
"aiohttp",
]
def _is_html_needed(user_agent):

View File

@ -43,7 +43,7 @@ class RepositoryAdapter(Adapter):
self._cheatsheet_files_prefix,
topic)
if os.path.exists(filename):
if os.path.exists(filename) and not os.path.isdir(filename):
answer = self._format_page(open(filename, 'r').read())
else:
# though it should not happen
@ -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):

View File

@ -39,7 +39,7 @@ If the problem persists, file a GitHub issue at
github.com/chubin/cheat.sh or ping @igor_chubin
"""
NOT_AUTHORIZED_MESSAGE = """403 UNAUTHORIZED"
NOT_AUTHORIZED_MESSAGE = """403 UNAUTHORIZED"""
class Question(UpstreamAdapter):
@ -113,13 +113,14 @@ class Question(UpstreamAdapter):
else:
topic = [topic]
if request_option.get("action") == "suggest":
if request_option.get("authorized"):
if request_options.get("action") == "suggest":
if request_options.get("authorized"):
topic = ["--action", "suggest"] + topic
else:
return NOT_AUTHORIZED_MESSAGE
cmd = [CONFIG["path.internal.bin.upstream"]] + topic
print(cmd)
proc = Popen(cmd, stdin=open(os.devnull, "r"), stdout=PIPE, stderr=PIPE)
answer = proc.communicate()[0].decode('utf-8')

View File

@ -73,15 +73,16 @@ class Tldr(GitRepositoryAdapter):
and as soon as anything is found, format and return it.
"""
search_order = ['common', 'linux', 'osx', 'sunos', 'windows']
search_order = ['common', 'linux', 'osx', 'sunos', 'windows', "android"]
local_rep = self.local_repository_location()
ext = self._cheatsheet_files_extension
filename = None
for subdir in search_order:
filename = os.path.join(
_filename = os.path.join(
local_rep, 'pages', subdir, "%s%s" % (topic, ext))
if os.path.exists(filename):
if os.path.exists(_filename):
filename = _filename
break
if filename:

View File

@ -94,6 +94,21 @@ def cheat_wrapper(query, request_options=None, output_format='ansi'):
# query = _strip_hyperlink(query.rstrip('/'))
topic, keyword, search_options = _parse_query(query)
# Process special case when 'action' is specified.
# In this case the response must be returned as is,
# without any changes and postprocessing
#
# 'action' is specified for suggestion queries, link queries etc.
if request_options.get("action"):
answers = get_answers(topic, request_options=request_options)
if answers:
answer = answers[0]
if isinstance(answer, dict):
answer = answer.get("answer", "")
return answer, True
else:
return "", False
if keyword:
answers = find_answers_by_keyword(
topic, keyword, options=search_options, request_options=request_options)
@ -116,5 +131,5 @@ def cheat_wrapper(query, request_options=None, output_format='ansi'):
answer_data['topics_list'] = get_topics_list()
return frontend.html.visualize(answer_data, request_options)
elif output_format == 'json':
return json.dumps(answer_data, indent=4)
return json.dumps(answer_data, indent=4), True
return frontend.ansi.visualize(answer_data, request_options)

View File

@ -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

View File

@ -96,7 +96,7 @@ def _render_html(query, result, editable, repository_button, topics_list, reques
curl_line = "<span class='pre'>$ curl cheat.sh/</span>"
if query == ':firstpage':
query = ""
form_html = ('<form action="/" method="GET"/>'
form_html = ('<form action="/" method="GET">'
'%s%s'
'<input'
' type="text" value="%s" name="topic"'

View File

@ -188,6 +188,15 @@ class Router(object):
if topic_type and topic_type in topic_types:
topic_types = [topic_type]
# Process action-queries directly, without caching and postprocessing
if request_options.get("action"):
answers = []
for topic_type in topic_types:
answers.append(
self._get_page_dict(topic, topic_type, request_options=request_options))
return answers
# 'question' queries are pretty expensive, that's why they should be handled
# in a special way:
# we do not drop the old style cache entries and try to reuse them if possible

View File

@ -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.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
@ -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,13 +702,17 @@ 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
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"

View File

@ -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

View File

@ -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

View File

@ -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.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
@ -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,13 +702,17 @@ 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
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"