Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posix sh #237

Open
wants to merge 116 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
4ee91e6
Get rid of unnecessary bashisms.
grayed Oct 3, 2020
de8bea6
Unbreak passing arguments to ftp(1)/curl(1)
grayed Oct 3, 2020
e840c39
One more invalid arguments expansion.
grayed Oct 3, 2020
23c7e84
Reset OPTIND before running getopts, since it may happen more than once.
grayed Oct 3, 2020
fbe85fe
Make "local" more portable
grayed Oct 3, 2020
202d031
more shell compatibility goo
grayed Oct 3, 2020
c14e8d7
drop --color=always, it doesn't exist outside GNU world
grayed Oct 5, 2020
2b3dc33
Initial version of CI
grayed Oct 7, 2020
4c68eaf
Minor simplification while here.
grayed Oct 7, 2020
c601c61
fix: replaced hardcoded paths '$HOME/.cht.sh' on $CHTSH_HOME, to prop…
WANDEX Aug 15, 2020
9283d17
Fix typo
alexfertel Oct 30, 2020
5714240
.travis.yml Use `curl` with connection timeout
abitrolly Nov 4, 2020
fa8ad4d
Use `curl` retry flags for waiting for service
abitrolly Nov 4, 2020
77b4369
Try newer Ubuntu with newer `curl`
abitrolly Nov 4, 2020
14d6ef0
Use `wget` instead of `curl` to wait for container
abitrolly Nov 4, 2020
4bc39db
Use `flask run` server for debugging
abitrolly Nov 4, 2020
6b8aeaf
Test "production" container on Travis
abitrolly Nov 12, 2020
4401bc3
Move all server init into `before_install:` section
abitrolly Nov 12, 2020
803b8e1
Run GitHub tests on Ubuntu 20.04
abitrolly Nov 12, 2020
cd6e386
Create logdir for fetch
chubin Nov 12, 2020
286ae8e
Update lib/fetch.py
chubin Nov 12, 2020
6309536
Update tests/results/15 (python/:learn)
chubin Nov 12, 2020
45e7ce0
Add python-Levenshtein to requirements.txt
chubin Nov 12, 2020
260b672
Fetch cheat sheets in GitHub actions
abitrolly Nov 12, 2020
6a8896f
Python 3 is default on 20.04+
abitrolly Nov 12, 2020
38f3b69
Run GitHub build every week at Thursday 9am
abitrolly Nov 12, 2020
4639d68
Added a check on get_answer_dict that identifies random requests
fedebuonco Nov 5, 2020
e01333b
Remved /:list from the possible random choice
fedebuonco Nov 5, 2020
cba1884
removed rosetta/ and '' from possible random choices
fedebuonco Nov 7, 2020
5a4d5b6
Fixed comments regarding :random
fedebuonco Nov 7, 2020
2040c57
Fixed typo
fedebuonco Nov 7, 2020
0e65fc4
Minor fix on checking if is a random request
fedebuonco Nov 7, 2020
f20a71f
Added a line on the readme
fedebuonco Nov 7, 2020
fbe956c
Another check if a given topic has just the :list and rosetta/
fedebuonco Nov 7, 2020
6e1c3d8
Fixed readme & style, removed special cases from random pool.
fedebuonco Nov 9, 2020
8942d41
Further removing of special cases
fedebuonco Nov 10, 2020
3c88b52
Show package versions
chubin Nov 13, 2020
1056ac9
Upgrade packages if they are already installed
chubin Nov 13, 2020
cf892b4
Remove pip freeze from ci
chubin Nov 13, 2020
1f0ce07
Install python requirements in Dockerfile (ci)
chubin Nov 13, 2020
1ce75de
Try to build container with GitHub Actions
abitrolly Nov 13, 2020
485614f
Port .travis.yml to GitHub Actions
abitrolly Nov 13, 2020
e8e26bc
Fix invalid .yml for Actions
abitrolly Nov 13, 2020
e59502b
Move pip3 to right place
chubin Nov 13, 2020
a924774
Move pip3 to right place
chubin Nov 13, 2020
c097a43
Copy requirements.txt
chubin Nov 13, 2020
89f04f7
Upgrade pygments
chubin Nov 13, 2020
2e61d2b
Disable caching for UpstreamAdapter
chubin Nov 16, 2020
ae25b7e
Reorder commands in Dockerfile
chubin Nov 16, 2020
3da4aea
Return 'cache' property in answer_dict
chubin Nov 16, 2020
5f425f7
Try to build container with GitHub Actions
abitrolly Nov 13, 2020
27d3720
Clean up Travis files
abitrolly Nov 13, 2020
e2e24f8
Added :random to the help page.
fedebuonco Nov 15, 2020
7eee26a
Decouple Flask `app` from `gevent` monkeypatching
abitrolly Nov 16, 2020
0593f32
Update tests/results/7 (:random)
chubin Nov 16, 2020
9970ee3
Remove explicit `gevent` imports
abitrolly Nov 17, 2020
6f7c87b
Properly setup Flask logging to stderr
abitrolly Nov 17, 2020
9e4a5fe
Show all cheat sheets when several found
chubin Nov 22, 2020
667edab
Update tests
chubin Nov 22, 2020
efc8308
Continue if response found in cache
chubin Nov 22, 2020
880ef6f
Update results/17 (az)
chubin Nov 22, 2020
382f0ee
Update lib/routing.py
chubin Nov 23, 2020
3313b06
Hotfix unicode processing for Python 3 (fixes #265)
chubin Nov 29, 2020
d5ae133
Remove broken fonts stylesheet
madsmtm Dec 10, 2020
322ce4c
Add OpenSearch description format file
madsmtm Dec 10, 2020
2de4672
Make the search quicker by not going through ?topic=
madsmtm Dec 10, 2020
a8871b2
Show non-printable chars in failed tests
abitrolly Dec 10, 2020
3407b6b
Add doc/standalone.md
chubin Jan 1, 2021
8ffb7c1
Add reference do doc/standalone.md (#14, #97, #98)
chubin Jan 1, 2021
f3ede89
Add powershell to PLAIN_TEXT_AGENTS (#273)
chubin Jan 10, 2021
6bc8c62
Use sql comments for psql (#276)
chubin Jan 17, 2021
d2190d2
Add NOT_FOUND_MESSAGE to adapter/question.py
chubin Jan 24, 2021
7168f98
Add aiohttp as a plain text agent
ChrisLovering Jan 31, 2021
d014f0e
Help text: remove outdated info, fix spelling
thezeroalpha Feb 16, 2021
810947b
Fix test
thezeroalpha Feb 16, 2021
8a650a7
README - small changes
floer32 Feb 16, 2021
7a8d5e9
README - small changes - add some horizontal-rules
floer32 Feb 16, 2021
404fe65
README - small changes - for those newer to sh
floer32 Feb 16, 2021
c3676f4
Use live badge for source repos' users/stars
bl-ue Feb 27, 2021
979b2ad
Remove unused links
bl-ue Feb 27, 2021
96464a2
Fix w3c validator error about self-closing `<form>`
abitrolly Mar 5, 2021
deb508c
Fix syntax highlight in README
Sea-n Mar 18, 2021
f3b77b0
Fix typo in README
Sea-n Mar 18, 2021
3973cc8
Use icons for source repos' users/stars
bl-ue Feb 28, 2021
c2892a8
Update README.md
bl-ue Feb 28, 2021
7f7a6e8
Users/Contributors
chubin Apr 6, 2021
04744cf
Ran doctoc to generate a table of contents (toc) https://github.com/t…
julien-tremblay-mclellan Mar 28, 2019
250b115
Update TOC
chubin Apr 22, 2021
219f372
Fix some unescaped shell colors.
aokellermann Jan 21, 2021
3042e4b
Bump cht.sh (client) version
chubin Apr 23, 2021
9c7b60c
Add support for wl-copy/Wayland
CodeLongAndProsper90 Apr 23, 2021
55046c7
Add wayland support to stealth-mode
CodeLongAndProsper90 Apr 23, 2021
4f4bcfe
Fix typographical error
CodeLongAndProsper90 Apr 23, 2021
77caf7e
Bump cht.sh version
chubin Apr 25, 2021
5f17d6e
Call virtualenv directly (cht.sh)
chubin Apr 25, 2021
358dd5f
Decode bytes to str (fetch.py) (fixes #291)
chubin Apr 25, 2021
92dc89e
Add doc how to switch caching off (#291)
chubin Apr 25, 2021
4f8e4da
Update tests
abitrolly Oct 17, 2021
03078d6
move nested function outside scope
Jan200101 Oct 15, 2021
14b4930
Add test for section splitting (for #312)
abitrolly Oct 22, 2021
a1c2958
Downgrade `colored` to fix tests
abitrolly Nov 13, 2021
5a274f2
Catch edge cases were delimiters are wrongfully caught
Jan200101 Oct 24, 2021
88007ee
add generic test cases
Jan200101 Oct 23, 2021
bb0af51
Simplify handling of query with multiple spaces
abitrolly Nov 13, 2021
69c95ca
`g++` workaround could still strip ++ if more ++ were encountered
abitrolly Nov 13, 2021
f8e27bc
docker: remove compose file with missing prebuilt image
abitrolly Nov 12, 2021
f7f5d6f
docker-compose: always mount source volume
abitrolly Nov 12, 2021
549389d
docker: update Alpine image (doesn't fix ansi2html issue)
abitrolly Nov 12, 2021
6ad8818
docker: install GNU sed to fix ansi2html (fixes #274, #301)
abitrolly Nov 12, 2021
cb4cf74
docker: setuptools is needed by gevent
abitrolly Nov 13, 2021
57604e5
Fix #307 error reporting on fetch failures
abitrolly Oct 2, 2021
8ae2a25
Better fix for #307 is to return text stream from Popen
abitrolly Nov 13, 2021
8182550
fetch.py: report when files are already downloaded
abitrolly Nov 13, 2021
6de51bc
.dockerignore: no Travis anymore
abitrolly Nov 16, 2021
43da9fc
`gevent` dependency fix on `setuptools` is merged to Alpine
abitrolly Nov 16, 2021
cb0439b
Get rid of unnecessary bashisms.
grayed Oct 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.travis.yml
.git
.gitignore
docker-compose.yml
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/tests-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Ubuntu Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '0 9 * * 4'

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: pip install --upgrade -r requirements.txt
- name: fetch upstream cheat sheets
run: python lib/fetch.py fetch-all
- name: run bash tests
run: bash tests/run-tests.sh
- name: run pytest
run: pytest lib/

docker:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: docker-compose build
- run: docker images
- run: |
docker-compose -f docker-compose.yml up -d
# docker-compose -f docker-compose.yml -f docker-compose.debug.yml up -d
docker-compose ps
# wait until the web server is up
wget --timeout 3 --tries=5 --spider localhost:8002 2>&1 | grep -i http
docker-compose logs --no-color
- run: CHEATSH_TEST_STANDALONE=NO bash tests/run-tests.sh
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
FROM alpine:3.12
FROM alpine:3.14
# fetching cheat sheets
## installing dependencies
RUN apk add --update --no-cache git py3-six py3-pygments py3-yaml py3-gevent \
libstdc++ py3-colorama py3-requests py3-icu py3-redis
## building missing python packages
RUN apk add --no-cache --virtual build-deps py3-pip g++ python3-dev \
&& pip3 install --no-cache-dir rapidfuzz colored polyglot pycld2 \
&& apk del build-deps
libstdc++ py3-colorama py3-requests py3-icu py3-redis sed
## copying
WORKDIR /app
COPY . /app
## building missing python packages
RUN apk add --no-cache --virtual build-deps py3-pip g++ python3-dev libffi-dev \
&& pip3 install --no-cache-dir --upgrade pygments \
&& pip3 install --no-cache-dir -r requirements.txt \
&& apk del build-deps
# fetching dependencies
RUN mkdir -p /root/.cheat.sh/log/ \
&& python3 lib/fetch.py fetch-all

Expand Down
91 changes: 58 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -15,22 +16,21 @@ 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).

[![Build Status](https://travis-ci.org/chubin/cheat.sh.svg?branch=master)](https://travis-ci.org/chubin/cheat.sh)

## Features

**cheat.sh**

* Has a simple curl/browser interface.
* 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.
* 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 and making sounds.
* Supports a special stealth mode where it can be used fully invisibly without ever touching a key and making sounds.

<p align="center">
<img src='https://cheat.sh/files/demo-curl.gif'/>
Expand All @@ -44,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)
Expand Down Expand Up @@ -188,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
Expand All @@ -203,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`
Expand Down Expand Up @@ -301,21 +307,21 @@ 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"
```

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

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
```
Expand All @@ -327,22 +333,24 @@ 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
```

----

### Stealth mode

Being used fully unnoticed is one of the most important property of any cheat sheet.
Expand Down Expand Up @@ -443,6 +451,8 @@ You can also use [`scoop`](https://github.com/lukesampson/scoop) command-line in
scoop install cht
```

----

## Self-Hosting

### Docker
Expand Down Expand Up @@ -530,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.

Expand Down Expand Up @@ -658,6 +668,7 @@ 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
Expand Down Expand Up @@ -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):

Expand Down Expand Up @@ -865,3 +878,15 @@ If you want to add a cheat sheet repository to cheat.sh, please open an issue:
* [Add a new repository](https://github.com/chubin/cheat.sh/issues/new)

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](doc/standalone.md)
Loading