mirror of
https://github.com/cheat/cheat.git
synced 2025-09-04 02:58:29 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
edd7b5e806 | |||
7abb663bf4 | |||
f6f1233b12 | |||
b9241efab1 | |||
8019325f1e | |||
c1fbeffde5 |
@ -3,15 +3,23 @@ Contributing
|
|||||||
If you would like to contribute cheetsheets or program functionality, please
|
If you would like to contribute cheetsheets or program functionality, please
|
||||||
fork this repository, make your changes, and submit a pull request.
|
fork this repository, make your changes, and submit a pull request.
|
||||||
|
|
||||||
|
|
||||||
|
## Python standards ##
|
||||||
Python code should conform to [PEP 8][].
|
Python code should conform to [PEP 8][].
|
||||||
|
|
||||||
Licensing
|
|
||||||
---------
|
|
||||||
By contributing to the project, you agree to license your work under the same
|
|
||||||
licenses as `cheat` itself. `cheat` is currently dual-licensed under the GPL3
|
|
||||||
and MIT licenses, though that could change without notice in the future.
|
|
||||||
|
|
||||||
`cheat`, however, will always remain free software (as in both "free as in
|
## Cheatsheet Format ##
|
||||||
freedom" and "free as in beer") and shall always be licensed accordingly.
|
Please pattern your cheatsheets after the following:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# To extract an uncompressed archive:
|
||||||
|
tar -xvf /path/to/foo.tar
|
||||||
|
|
||||||
|
# To create an uncompressed archive:
|
||||||
|
tar -cvf /path/to/foo.tar /path/to/foo/
|
||||||
|
|
||||||
|
# To extract a .gz archive:
|
||||||
|
tar -xzvf /path/to/foo.tgz
|
||||||
|
```
|
||||||
|
|
||||||
[PEP 8]: http://legacy.python.org/dev/peps/pep-0008/
|
[PEP 8]: http://legacy.python.org/dev/peps/pep-0008/
|
||||||
|
27
README.md
27
README.md
@ -1,5 +1,4 @@
|
|||||||
[](https://pypi.python.org/pypi/cheat/)
|
[](https://pypi.python.org/pypi/cheat/)
|
||||||
[](https://pypi.python.org/pypi/cheat/)
|
|
||||||
|
|
||||||
cheat
|
cheat
|
||||||
=====
|
=====
|
||||||
@ -74,7 +73,7 @@ variable set, you may edit cheatsheets with:
|
|||||||
cheat -e foo
|
cheat -e foo
|
||||||
```
|
```
|
||||||
|
|
||||||
If the 'foo' cheatsheet already exists, it will be opened for editing.
|
If the `foo` cheatsheet already exists, it will be opened for editing.
|
||||||
Otherwise, it will be created automatically.
|
Otherwise, it will be created automatically.
|
||||||
|
|
||||||
After you've customized your cheatsheets, I urge you to track `~/.cheat/` along
|
After you've customized your cheatsheets, I urge you to track `~/.cheat/` along
|
||||||
@ -110,13 +109,32 @@ export CHEATPATH="$CHEATPATH:/path/to/more/cheats"
|
|||||||
You may view which directories are on your `CHEATPATH` with `cheat -d`.
|
You may view which directories are on your `CHEATPATH` with `cheat -d`.
|
||||||
|
|
||||||
### Enabling Syntax Highlighting ###
|
### Enabling Syntax Highlighting ###
|
||||||
`cheat` can apply syntax highlighting to your cheatsheets if so desired. To
|
`cheat` can optionally apply syntax highlighting to your cheatsheets. To enable
|
||||||
enable this feature, set a `CHEATCOLORS` environment variable:
|
syntax highlighting, export a `CHEATCOLORS` environment variable:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export CHEATCOLORS=true
|
export CHEATCOLORS=true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Specifying a Syntax Highlighter ####
|
||||||
|
You may manually specify which syntax highlighter to use for each cheatsheet by
|
||||||
|
wrapping the sheet's contents in a [Github-Flavored Markdown code-fence][gfm].
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
```sql
|
||||||
|
-- to select a user by ID
|
||||||
|
SELECT *
|
||||||
|
FROM Users
|
||||||
|
WHERE id = 100
|
||||||
|
```
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
If no syntax highlighter is specified, the `bash` highlighter will be used by
|
||||||
|
default.
|
||||||
|
|
||||||
|
|
||||||
See Also:
|
See Also:
|
||||||
---------
|
---------
|
||||||
- [Enabling Command-line Autocompletion][autocompletion]
|
- [Enabling Command-line Autocompletion][autocompletion]
|
||||||
@ -125,5 +143,6 @@ See Also:
|
|||||||
|
|
||||||
[autocompletion]: https://github.com/chrisallenlane/cheat/wiki/Enabling-Command-line-Autocompletion
|
[autocompletion]: https://github.com/chrisallenlane/cheat/wiki/Enabling-Command-line-Autocompletion
|
||||||
[dotfiles]: http://dotfiles.github.io/
|
[dotfiles]: http://dotfiles.github.io/
|
||||||
|
[gfm]: https://help.github.com/articles/creating-and-highlighting-code-blocks/
|
||||||
[installing]: https://github.com/chrisallenlane/cheat/wiki/Installing
|
[installing]: https://github.com/chrisallenlane/cheat/wiki/Installing
|
||||||
[related-projects]: https://github.com/chrisallenlane/cheat/wiki/Related-Projects
|
[related-projects]: https://github.com/chrisallenlane/cheat/wiki/Related-Projects
|
||||||
|
@ -42,7 +42,7 @@ from docopt import docopt
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# parse the command-line options
|
# parse the command-line options
|
||||||
options = docopt(__doc__, version='cheat 2.1.28')
|
options = docopt(__doc__, version='cheat 2.2.0')
|
||||||
|
|
||||||
# list directories
|
# list directories
|
||||||
if options['--directories']:
|
if options['--directories']:
|
||||||
|
@ -13,14 +13,23 @@ def colorize(sheet_content):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from pygments import highlight
|
from pygments import highlight
|
||||||
from pygments.lexers import BashLexer
|
from pygments.lexers import get_lexer_by_name
|
||||||
from pygments.formatters import TerminalFormatter
|
from pygments.formatters import TerminalFormatter
|
||||||
|
|
||||||
# if pygments can't load, just return the uncolorized text
|
# if pygments can't load, just return the uncolorized text
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return sheet_content
|
return sheet_content
|
||||||
|
|
||||||
return highlight(sheet_content, BashLexer(), TerminalFormatter())
|
first_line = sheet_content.splitlines()[0]
|
||||||
|
lexer = get_lexer_by_name('bash')
|
||||||
|
if first_line.startswith('```'):
|
||||||
|
sheet_content = '\n'.join(sheet_content.split('\n')[1:-2])
|
||||||
|
try:
|
||||||
|
lexer = get_lexer_by_name(first_line[3:])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return highlight(sheet_content, lexer, TerminalFormatter())
|
||||||
|
|
||||||
|
|
||||||
def die(message):
|
def die(message):
|
||||||
|
2
setup.py
2
setup.py
@ -3,7 +3,7 @@ import os
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = 'cheat',
|
name = 'cheat',
|
||||||
version = '2.1.28',
|
version = '2.2.0',
|
||||||
author = 'Chris Lane',
|
author = 'Chris Lane',
|
||||||
author_email = 'chris@chris-allen-lane.com',
|
author_email = 'chris@chris-allen-lane.com',
|
||||||
license = 'GPL3',
|
license = 'GPL3',
|
||||||
|
Reference in New Issue
Block a user