cheat

command module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 19 Imported by: 0

README

cheat

CircleCI GitHub release MIT License Go Report Card PRs Welcome

cheat allows you to create, view, and edit cheatsheets on the command-line.

This project is a re-implementation of Chris Lane's cheatsheet script in Go along with a few added features and some opinionated formatting & colorization.

Install

Option 1: Binary

Download the latest release from https://github.com/jakewarren/cheat/releases/latest

Option 2: From source
go get github.com/jakewarren/cheat

Usage

Configuring

cheat is configured by a JSON file located at ~/.cheatrc. A default config will be generated for you:

{
    "highlight": true,
    "cheatdirs": [
        "~/.cheat"
    ],
    "editor": "vim"
}
Configuration Option Description
highlight controls the colorization of the output
cheatdirs an array of directories to search for cheatsheets in. when a new cheatsheet is created, it will be placed in the first directory specified.
editor specifies the editor to be called when editing a cheat sheet
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 git     # file is named "git"

Example cheatsheet syntax (left) and display (right):

Bash Completion

To enable bash completion for cheat place the following in your ~/.bashrc file:

function _cheat_autocomplete {
    sheets=$(cheat -l | cut -d' ' -f1)
    COMPREPLY=()
    # $cur contains the current word the user is entering and is built from:
    #   @COMP_WORDS - array of individual words in the current command line
    #   $COMP_CWORD - index variable into @COMP_WORDS of the word containing the current cursor position
    cur="${COMP_WORDS[COMP_CWORD]}"
    # $prev contains the previous word the user entered
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    if [ $COMP_CWORD = 1 ]; then
        COMPREPLY=(`compgen -W "$sheets" -- $2`)
    fi

        #provide completion for the second word
    if [[ $COMP_CWORD == 2 && $prev == "-e" ]] ; then
        COMPREPLY=(`compgen -W "$sheets" -- $2`)
    fi
}

complete -F _cheat_autocomplete cheat

Acknowledgements

Changes

All notable changes to this project will be documented in the changelog.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

License

MIT © 2019 Jake Warren

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL