项目作者: cheat

项目描述 :
cheat allows you to create and view interactive cheatsheets on the command-line. It was designed to help remind *nix system administrators of options for commands that they use frequently, but not frequently enough to remember.
高级语言: Go
项目地址: git://github.com/cheat/cheat.git
创建时间: 2013-07-30T01:32:12Z
项目社区:https://github.com/cheat/cheat

开源协议:MIT License

下载


Workflow status

cheat

cheat allows you to create and view interactive cheatsheets on the
command-line. It was designed to help remind *nix system administrators of
options for commands that they use frequently, but not frequently enough to
remember.

The obligatory xkcd

Use cheat with cheatsheets.

Example

The next time you’re forced to disarm a nuclear weapon without consulting
Google, you may run:

  1. cheat tar

You will be presented with a cheatsheet resembling the following:

  1. # To extract an uncompressed archive:
  2. tar -xvf '/path/to/foo.tar'
  3. # To extract a .gz archive:
  4. tar -xzvf '/path/to/foo.tgz'
  5. # To create a .gz archive:
  6. tar -czvf '/path/to/foo.tgz' '/path/to/foo/'
  7. # To extract a .bz2 archive:
  8. tar -xjvf '/path/to/foo.tgz'
  9. # To create a .bz2 archive:
  10. tar -cjvf '/path/to/foo.tgz' '/path/to/foo/'

Usage

To view a cheatsheet:

  1. cheat tar # a "top-level" cheatsheet
  2. cheat foo/bar # a "nested" cheatsheet

To edit a cheatsheet:

  1. cheat -e tar # opens the "tar" cheatsheet for editing, or creates it if it does not exist
  2. cheat -e foo/bar # nested cheatsheets are accessed like this

To view the configured cheatpaths:

  1. cheat -d

To list all available cheatsheets:

  1. cheat -l

To list all cheatsheets that are tagged with “networking”:

  1. cheat -l -t networking

To list all cheatsheets on the “personal” path:

  1. cheat -l -p personal

To search for the phrase “ssh” among cheatsheets:

  1. cheat -s ssh

To search (by regex) for cheatsheets that contain an IP address:

  1. cheat -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'

Flags may be combined in intuitive ways. Example: to search sheets on the
“personal” cheatpath that are tagged with “networking” and match a regex:

  1. cheat -p personal -t networking --regex -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'

Installing

For installation and configuration instructions, see INSTALLING.md.

Cheatsheets

Cheatsheets are plain-text files with no file extension, and are named
according to the command used to view them:

  1. cheat tar # file is named "tar"
  2. cheat foo/bar # file is named "bar", in a "foo" subdirectory

Cheatsheet text may optionally be preceeded by a YAML frontmatter header that
assigns tags and specifies syntax:

  1. ---
  2. syntax: javascript
  3. tags: [ array, map ]
  4. ---
  5. // To map over an array:
  6. const squares = [1, 2, 3, 4].map(x => x * x);

The cheat executable includes no cheatsheets, but community-sourced
cheatsheets are available
. You will be asked if you would like to
install the community-sourced cheatsheets the first time you run cheat.

Cheatpaths

Cheatsheets are stored on “cheatpaths”, which are directories that contain
cheatsheets. 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:

  1. # conf.yml:
  2. # ...
  3. cheatpaths:
  4. - name: community # a name for the cheatpath
  5. path: ~/documents/cheat/community # the path's location on the filesystem
  6. tags: [ community ] # these tags will be applied to all sheets on the path
  7. readonly: true # if true, `cheat` will not create new cheatsheets here
  8. - name: personal
  9. path: ~/documents/cheat/personal # this is a separate directory and repository than above
  10. tags: [ personal ]
  11. readonly: false # new sheets may be written here
  12. # ...

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.

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.

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.

Autocompletion

Shell autocompletion is currently available for bash, fish, and zsh. Copy
the relevant completion script into the appropriate directory on
your filesystem to enable autocompletion. (This directory will vary depending
on operating system and shell specifics.)

Additionally, cheat supports enhanced autocompletion via integration with
fzf. To enable fzf integration:

  1. Ensure that fzf is available on your $PATH
  2. Set an envvar: export CHEAT_USE_FZF=true