GithubHelp home page GithubHelp logo

cheatsheets's Introduction

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

cheatsheets's People

Contributors

bannmann avatar briandfoy avatar chrisallenlane avatar dude-with-the-long-username avatar ffranchina avatar gkspranger avatar glenacota avatar harrison-s1 avatar herbygillot avatar j1shnu avatar jazzabeanie avatar joeytwiddle avatar jonny-exe avatar kalaschnik avatar kreyren avatar kush avatar lengyijun avatar loreb avatar luciolebrillante avatar marcusnjones avatar mikeoertli avatar mlau-git avatar obalunenko avatar pankajbhanu avatar papanito avatar philclifford avatar shuber2 avatar tcpekin avatar theweirddev avatar thirdscript avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cheatsheets's Issues

Very slow pull request merging?

I just wanted to ask if there is active administration

Cheat is an awesome project and I want to contribute to it, as there are many commands missing.

The system with tags and all is very good, and I tried to explain everything best.

But it seems for now noone even looked at these additions, and there are 27 more left open.

Specify one valid placeholder path format

This issue aims to make pages standardized and more readable.

Format:

  • <path/to/file>
  • <path/to/directory>
  • <path/to/file1 path/to/file2 ...>
  • <path/to/directory1 path/to/directory2 ...>

find

find . -type f -ctime -48h

find: invalid argument `-48h' to `-ctime'

How to draw table in cheatsheets

Rust         | Cpp              |                      
=============|==================|=====================|=======================
a:&T         | const T* const a | 都不能修改          | 不可变引用的不可变绑定
mut a:&T     | const T* a       | 不能修改a指向的内容 | 不可变引用的可变绑定
a:&mut T     | T* const a       | 不能修改a           | 可变引用的不可变绑定
mut a:&mut T | T*a              | 都能修改            | 可变引用的可变绑定

Currently, I draw table like this. Is there any way to make more complex table?

Tags syntax

The syntax for tags is incorrect for many files. tags should be followed by a colon (:) in order to work with the -t option. For example, look at the tag lines for files tagged with networking.

dhclient:tags: [ networking ]
ip:tags [ networking ]
iptables:tags [ networking ]
iwconfig:tags [ networking ]
nc:tags [ networking ]
ncat:tags [ networking ]
netstat:tags [ networking ]
nmap:tags [ networking ]
nmcli:tags [ networking ]
ping:tags [ networking ]
ping6:tags [ networking ]
route:tags [ networking ]
socat:tags [ networking ]
sockstat:tags [ networking ]
ss:tags [ networking ]

Only the tag for dhclient is picked up with the -t option (note the colon after tags: for dhclient in the output above).

$ cheat -l -t networking
title:        file:                                                    tags:
dhclient ./cheatsheets/community/dhclient      community,networking

Replace markdown Heading syntax by # Headings

In the Markdown Cheatsheet it says
# headers
h1 header
=========
h2 header
---------

I think it would be better to have sth like
"# h1 heading"
"###### h6 heading"
# (without double quotes")
the markdown #heading syntax should be prefered because its more universal.
the only point against this is that it could be confused with the # coment synthax in bash and in the cheat sheat.
I think that the way mentioned above is a good workaround

Cheatsheet for go

I'll add cheatsheet for golang toolchain more common used commands.

The description of commands could be find here

Cheatsheet for Regex

I think we should create one for Regex

I might do it later, but I'm pretty busy right now and I also am far from a regex expert. If someone has time to do it soon, I suggest they go for it!

License of the repo

In order to allow collaboration, this repository should have a license. As a content-based repo (containing text, rather than runnable software), I would suggest a license like CC-BY 4.0; that's what we're adopting at tldr-pages.

raw file accesss via url no longer working

Hi!
I love this little tool and set of instructions. I was using it quite often about a year ago. Now suddenly it doesn't work anymore. It seem that GitHub have borked up this functionality.

The following used to work from command line:

curl -sS https://raw.githubusercontent.com/cheat/cheat/master/cheat/cheatsheets/git

But now it just return a 404. So I tried various other combinations, but without success.

curl -sS https://github.com/cheat/cheatsheets/raw/master/git

# <html><body>You are being <a href="https://raw.githubusercontent.com/cheat/cheatsheets/master/git">redirected</a>.</body></html>

Contributing a useful tip for tmux integration

Sorry to pollute the issue queue with this but I wasn't sure where else to put it.

I wrote a couple of simple bash functions that make it easy to pull up and edit a cheat document in a new pane and close it from the command line when using tmux. Maybe it could be included in the documentation somewhere.

tmux_cheat_page() {
if [[ "$TERM" =~ 'screen' ]] && [[ -n "$CHEAT_EDITOR" ]]; then

  pane=$(tmux showw -v @tmux_cheat_pane)
  output=$(tmux list-panes -t ${pane} 2>&1)

  if [[ $pane ]] && ! [[ -z "$pane" ]] && ! [[ $output =~ 'find pane' ]]; then
    tmux -q respawn-pane -k -t $pane cheat -e $1
  else
    tmux split-window -vf cheat -e $1
    pane=$(tmux display-message -p "#{pane_id}")
    tmux setw @tmux_cheat_pane $pane
    tmux select-pane -t {last}
  fi

fi
}

tmux_cheat_page_close() {

  pane=$(tmux showw -v @tmux_cheat_pane)

  if [ $pane ]; then
     tmux kill-pane -t $pane
  fi
}

export -f tmux_cheat_page
export -f tmux_cheat_page_close

Cheatsheet for the `ed` line editor created

I've written a cheat sheet for ed, but to be honest I'm not sure how to actually create a pull request using Github's web interface, so it's below:

---
tags [ ed ]
---

# File and buffer management

:e {file}       load file to buffer
:q              quit
:Q              quit without saving changes
:f {name}       change buffer name
:w              write to file using current buffer name 
:w {file}       write buffer to new file
:wq             write buffer to existing file and exit

# Line-oriented addressing and movement 
#   `ed' uses line addresses to move around and operate within a buffer
#   Move to or operate on single lines by entering the line number
#   Move to or operate on ranges of lines using comma-separated values
#   The active line is always set to the last number of the range entered

. or p          display current line
n               display current line with line number

1,$ or ,        range indicating the entire buffer; displays final line

3 or 3p         move to line 3 of the buffer and display
3n              move to line 3 of the buffer and display with line number

1,$p or ,p      display entire buffer without line numbers
1,$n or ,n      display entire buffer with line numbers

15,25p          display lines 15 through 25 of the buffer
15,25n          display lines 15 through 25 of the buffer with line numbers

# Line editing commands
#   All commands can be prefixed with line addresses/ranges

i               start editing by inserting new text before the current line
a               start editing by inserting new text after the current line
c               clear contents of current line and replace with new text
.               a period [.] enterd alone on a new line ends the active edit

d               delete current line
1,3d            delete lines 1 through 3

u               undo last edit

r {file}        read contents of {file} into buffer after current line
r !{command}    read output of {command} into buffer after current line

# Example of a simple editing session

e test.txt                      edit file "test.txt"
45                              `ed' returns character count as confirmation
1,3n                            display lines 1 through 3 with line numbers
1    This is line 1           
2    This is line 2
3    This is line 3
2c                              change line 2
I am typing a new line 2
.                               end active edit 
1,3n                            display lines 1 thorugh 3 with line numbers
1    This is line 1
2    I am typing a new line 2
3    This is line 3
wq                              write file "test.txt" and exit

# Search
#   Accepts regexps in search strings

g/foo/          search all lines for `foo' and display matching lines
g/foo/n         search all lines for `foo'; display with line numbers

4,9/foo/        search lines 1 through 5 for `foo' and display matches 
4,9/foo/n       search lines 1 through 5 for `foo'; display with line numbers

# Replace
#   Accepts regexps in search and replace strings

s/foo/bar       replace first instance of `foo' with `bar' on the current line
s/foo/bar/{n}   replace {n}th instance of `foo' with `bar' on the current line
s/foo/bar/g     replace all instances of `foo' with `bar' on the current line

1,4/foo/bar/g   replace all instances of `foo' with `bar` in lines 1 through 4

,s/foo/bar/g    replace all instances of `foo' with `bar' in the entire buffer

How to use fzf with cheat?

I added export CHEAT_USE_FZF=true to .zshrc but I am not sure how to use cheat with fzf.
When using cheat ** fzf is running fuzzy search in filesystem but not in cheats.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.