cheat

cheat 允许你在命令行上创建和查看交互式小抄。它的设计目的是帮助提醒 *nix 系统管理员注意他们经常使用但又不常记住的命令选项。「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.」

Github星跟踪图

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:

cheat tar

You will be presented with a cheatsheet resembling the following:

# To extract an uncompressed archive:
tar -xvf '/path/to/foo.tar'

# To extract a .gz archive:
tar -xzvf '/path/to/foo.tgz'

# To create a .gz archive:
tar -czvf '/path/to/foo.tgz' '/path/to/foo/'

# To extract a .bz2 archive:
tar -xjvf '/path/to/foo.tgz'

# To create a .bz2 archive:
tar -cjvf '/path/to/foo.tgz' '/path/to/foo/'

Usage

To view a cheatsheet:

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

To edit a cheatsheet:

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

To view the configured cheatpaths:

cheat -d

To list all available cheatsheets:

cheat -l

To list all cheatsheets that are tagged with "networking":

cheat -l -t networking

To list all cheatsheets on the "personal" path:

cheat -l -p personal

To search for the phrase "ssh" among cheatsheets:

cheat -s ssh

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

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:

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:

cheat tar     # file is named "tar"
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:

---
syntax: javascript
tags: [ array, map ]
---
// To map over an array:
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:

# 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
# ...

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

主要指标

概览
名称与所有者cheat/cheat
主编程语言Go
编程语言 (语言数: 4)
平台
许可证MIT License
所有者活动
创建于2013-07-30 01:32:12
推送于2024-07-29 06:38:08
最后一次提交2024-01-08 15:34:48
发布数96
最新版本名称4.4.2 (发布于 2023-12-15 12:49:50)
第一版名称2.0.1 (发布于 2014-05-25 19:35:52)
用户参与
星数12.7k
关注者数188
派生数830
提交数1.3k
已启用问题?
问题数237
打开的问题数28
拉请求数381
打开的拉请求数15
关闭的拉请求数115
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?