2013-08-11 01:08:21 +02:00
|
|
|
cheat
|
2013-07-31 04:48:07 +02:00
|
|
|
=====
|
2019-10-27 23:44:44 +01:00
|
|
|
|
|
|
|
[![Build Status](https://travis-ci.com/cheat/cheat.svg?branch=master)](https://travis-ci.com/cheat/cheat)
|
|
|
|
|
2013-08-11 00:56:50 +02:00
|
|
|
`cheat` allows you to create and view interactive cheatsheets on the
|
2013-08-11 21:57:11 +02:00
|
|
|
command-line. It was designed to help remind \*nix system administrators of
|
2013-08-11 00:56:50 +02:00
|
|
|
options for commands that they use frequently, but not frequently enough to
|
|
|
|
remember.
|
|
|
|
|
|
|
|
![The obligatory xkcd](http://imgs.xkcd.com/comics/tar.png 'The obligatory xkcd')
|
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
Use `cheat` with [cheatsheets][].
|
|
|
|
|
2013-08-11 21:57:11 +02:00
|
|
|
|
2014-04-27 16:47:04 +02:00
|
|
|
Example
|
|
|
|
-------
|
2013-08-11 00:56:50 +02:00
|
|
|
The next time you're forced to disarm a nuclear weapon without consulting
|
|
|
|
Google, you may run:
|
|
|
|
|
2016-02-18 21:09:02 +01:00
|
|
|
```sh
|
|
|
|
cheat tar
|
|
|
|
```
|
2013-08-11 00:56:50 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
You will be presented with a cheatsheet resembling the following:
|
2013-08-11 00:56:50 +02:00
|
|
|
|
2016-02-18 21:09:02 +01:00
|
|
|
```sh
|
2019-10-27 23:44:44 +01:00
|
|
|
# To extract an uncompressed archive:
|
2016-02-18 21:09:02 +01:00
|
|
|
tar -xvf '/path/to/foo.tar'
|
2013-08-11 00:56:50 +02:00
|
|
|
|
2013-08-24 17:10:16 +02:00
|
|
|
# To extract a .gz archive:
|
2016-02-18 21:09:02 +01:00
|
|
|
tar -xzvf '/path/to/foo.tgz'
|
2013-08-11 00:56:50 +02:00
|
|
|
|
2013-08-24 17:10:16 +02:00
|
|
|
# To create a .gz archive:
|
2016-02-18 21:09:02 +01:00
|
|
|
tar -czvf '/path/to/foo.tgz' '/path/to/foo/'
|
2013-08-11 00:56:50 +02:00
|
|
|
|
2013-08-24 17:10:16 +02:00
|
|
|
# To extract a .bz2 archive:
|
2016-02-18 21:09:02 +01:00
|
|
|
tar -xjvf '/path/to/foo.tgz'
|
2013-08-11 00:56:50 +02:00
|
|
|
|
2013-08-24 17:10:16 +02:00
|
|
|
# To create a .bz2 archive:
|
2016-02-18 21:09:02 +01:00
|
|
|
tar -cjvf '/path/to/foo.tgz' '/path/to/foo/'
|
2013-08-11 00:56:50 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Installing
|
2014-04-27 16:47:04 +02:00
|
|
|
----------
|
2019-10-20 16:02:28 +02:00
|
|
|
`cheat` has no dependencies. To install it, download the executable from the
|
|
|
|
[releases][] page and place it on your `PATH`.
|
|
|
|
|
|
|
|
|
|
|
|
Configuring
|
|
|
|
-----------
|
|
|
|
### conf.yml ###
|
2020-03-07 02:17:26 +01:00
|
|
|
`cheat` is configured by a YAML file that will be auto-generated on first run.
|
|
|
|
Should you need to create a config file manually, you can do
|
|
|
|
so via:
|
2014-06-04 04:34:50 +02:00
|
|
|
|
2016-02-18 21:09:02 +01:00
|
|
|
```sh
|
2019-10-20 16:02:28 +02:00
|
|
|
mkdir -p ~/.config/cheat && cheat --init > ~/.config/cheat/conf.yml
|
2016-02-18 21:09:02 +01:00
|
|
|
```
|
2013-08-11 00:56:50 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
By default, the config file is assumed to exist on an XDG-compliant
|
|
|
|
configuration path like `~/.config/cheat/conf.yml`. If you would like to store
|
|
|
|
it elsewhere, you may export a `CHEAT_CONFIG_PATH` environment variable that
|
|
|
|
specifies its path:
|
2013-08-16 10:19:04 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
```sh
|
|
|
|
export CHEAT_CONFIG_PATH="~/.dotfiles/cheat/conf.yml"
|
|
|
|
```
|
2013-09-07 20:38:13 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
Cheatsheets
|
|
|
|
-----------
|
|
|
|
Cheatsheets are plain-text files with no file extension, and are named
|
|
|
|
according to the command used to view them:
|
2013-08-11 00:56:50 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
```sh
|
|
|
|
cheat tar # file is named "tar"
|
|
|
|
cheat foo/bar # file is named "bar", in a "foo" subdirectory
|
|
|
|
```
|
2014-04-27 16:47:04 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
Cheatsheet text may optionally be preceeded by a YAML frontmatter header that
|
|
|
|
assigns tags and specifies syntax:
|
2014-04-27 16:47:04 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
```
|
|
|
|
---
|
|
|
|
syntax: javascript
|
|
|
|
tags: [ array, map ]
|
|
|
|
---
|
|
|
|
// To map over an array:
|
|
|
|
const squares = [1, 2, 3, 4].map(x => x * x);
|
2016-02-18 21:09:02 +01:00
|
|
|
```
|
2013-08-11 00:56:50 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
The `cheat` executable includes no cheatsheets, but [community-sourced
|
2020-03-07 02:17:26 +01:00
|
|
|
cheatsheets are available][cheatsheets]. You will be asked if you would like to
|
|
|
|
install the community-sourced cheatsheets the first time you run `cheat`.
|
2013-08-11 00:56:50 +02:00
|
|
|
|
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
Cheatpaths
|
|
|
|
----------
|
|
|
|
Cheatsheets are stored on "cheatpaths", which are directories that contain
|
|
|
|
cheetsheets. Cheatpaths are specified in the `conf.yml` file.
|
|
|
|
|
|
|
|
It can be useful to configure `cheat` against multiple cheatpaths. A common
|
|
|
|
pattern is to store cheatsheets from multiple repositories on individual
|
|
|
|
cheatpaths:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
# conf.yml:
|
|
|
|
# ...
|
|
|
|
cheatpaths:
|
|
|
|
- name: community # a name for the cheatpath
|
|
|
|
path: ~/documents/cheat/community # the path's location on the filesystem
|
|
|
|
tags: [ community ] # these tags will be applied to all sheets on the path
|
|
|
|
readonly: true # if true, `cheat` will not create new cheatsheets here
|
|
|
|
|
|
|
|
- name: personal
|
|
|
|
path: ~/documents/cheat/personal # this is a separate directory and repository than above
|
|
|
|
tags: [ personal ]
|
|
|
|
readonly: false # new sheets may be written here
|
|
|
|
# ...
|
|
|
|
```
|
2013-08-11 00:56:50 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
The `readonly` option instructs `cheat` not to edit (or create) any cheatsheets
|
|
|
|
on the path. This is useful to prevent merge-conflicts from arising on upstream
|
|
|
|
cheatsheet repositories.
|
2013-08-22 05:00:22 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
If a user attempts to edit a cheatsheet on a read-only cheatpath, `cheat` will
|
|
|
|
transparently copy that sheet to a writeable directory before opening it for
|
|
|
|
editing.
|
|
|
|
|
2020-01-20 18:34:48 +01:00
|
|
|
### Directory-scoped Cheatpaths ###
|
|
|
|
At times, it can be useful to closely associate cheatsheets with a directory on
|
|
|
|
your filesystem. `cheat` facilitates this by searching for a `.cheat` folder in
|
|
|
|
the current working directory. If found, the `.cheat` directory will
|
|
|
|
(temporarily) be added to the cheatpaths.
|
2019-10-20 16:02:28 +02:00
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
To view a cheatsheet:
|
2013-08-29 17:19:19 +02:00
|
|
|
|
2016-02-18 21:09:02 +01:00
|
|
|
```sh
|
2019-10-20 16:02:28 +02:00
|
|
|
cheat tar # a "top-level" cheatsheet
|
|
|
|
cheat foo/bar # a "nested" cheatsheet
|
2016-02-18 21:09:02 +01:00
|
|
|
```
|
2013-08-29 17:19:19 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
To edit a cheatsheet:
|
2013-08-16 00:52:32 +02:00
|
|
|
|
2016-02-18 21:09:02 +01:00
|
|
|
```sh
|
2019-10-20 16:02:28 +02:00
|
|
|
cheat -e tar # opens the "tar" cheatsheet for editing, or creates it if it does not exist
|
|
|
|
cheat -e foo/bar # nested cheatsheets are accessed like this
|
2016-02-18 21:09:02 +01:00
|
|
|
```
|
2013-08-16 00:52:32 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
To view the configured cheatpaths:
|
2013-08-16 00:52:32 +02:00
|
|
|
|
2016-02-18 21:09:02 +01:00
|
|
|
```sh
|
2019-10-20 16:02:28 +02:00
|
|
|
cheat -d
|
2016-02-18 21:09:02 +01:00
|
|
|
```
|
2013-08-16 00:52:32 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
To list all available cheatsheets:
|
2013-08-22 05:00:22 +02:00
|
|
|
|
2016-02-18 21:09:02 +01:00
|
|
|
```sh
|
2019-10-20 16:02:28 +02:00
|
|
|
cheat -l
|
2016-02-18 21:09:02 +01:00
|
|
|
```
|
2013-08-22 05:35:04 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
To list all cheatsheets that are tagged with "networking":
|
2019-02-04 17:56:00 +01:00
|
|
|
|
|
|
|
```sh
|
2019-10-20 16:02:28 +02:00
|
|
|
cheat -l -t networking
|
2019-02-04 17:56:00 +01:00
|
|
|
```
|
2019-01-11 21:13:41 +01:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
To list all cheatsheets on the "personal" path:
|
2017-03-01 00:59:27 +01:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
```sh
|
|
|
|
cheat -l -p personal
|
|
|
|
```
|
2017-03-01 00:59:27 +01:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
To search for the phrase "ssh" among cheatsheets:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cheat -s ssh
|
2017-03-01 00:59:27 +01:00
|
|
|
```
|
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
To search (by regex) for cheatsheets that contain an IP address:
|
2017-03-01 00:59:27 +01:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
```sh
|
|
|
|
cheat -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
|
|
|
```
|
2019-01-11 22:36:17 +01:00
|
|
|
|
2019-11-05 15:53:21 +01:00
|
|
|
Flags may be combined in intuitive ways. Example: to search sheets on the
|
2019-10-20 16:02:28 +02:00
|
|
|
"personal" cheatpath that are tagged with "networking" and match a regex:
|
2019-01-11 22:36:17 +01:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
```sh
|
2019-11-05 15:53:21 +01:00
|
|
|
cheat -p personal -t networking --regex -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
2019-10-20 16:02:28 +02:00
|
|
|
```
|
2019-01-11 22:36:17 +01:00
|
|
|
|
2017-03-01 00:59:27 +01:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
Advanced Usage
|
|
|
|
--------------
|
2020-04-08 00:47:35 +02:00
|
|
|
Shell autocompletion is currently available for `bash`, `fish`, and `zsh`. Copy
|
|
|
|
the relevant [completion script][completions] into the appropriate directory on
|
|
|
|
your filesystem to enable autocompletion. (This directory will vary depending
|
|
|
|
on operating system and shell specifics.)
|
2014-08-07 04:04:19 +02:00
|
|
|
|
2020-02-02 20:50:16 +01:00
|
|
|
Additionally, `cheat` supports enhanced autocompletion via integration with
|
2020-04-08 00:47:35 +02:00
|
|
|
[fzf][]. To enable `fzf` integration:
|
2020-02-02 20:50:16 +01:00
|
|
|
|
|
|
|
1. Ensure that `fzf` is available on your `$PATH`
|
|
|
|
2. Set an envvar: `export CHEAT_USE_FZF=true`
|
2013-08-22 05:35:04 +02:00
|
|
|
|
2019-10-20 16:02:28 +02:00
|
|
|
[Releases]: https://github.com/cheat/cheat/releases
|
|
|
|
[cheatsheets]: https://github.com/cheat/cheatsheets
|
2020-02-27 01:20:24 +01:00
|
|
|
[completions]: https://github.com/cheat/cheat/tree/master/scripts
|
2019-10-20 16:02:28 +02:00
|
|
|
[fzf]: https://github.com/junegunn/fzf
|