Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add a summary view for cheat sheetsΒ #762

@BernardIgiri

Description

@BernardIgiri

Currently, I'm using a custom Fish function to list my cheat sheets along with a short summary of each:

function cheat-ls --wraps='cheat -lt [tag]'
    set tag personal
    if test (count $argv) -gt 0
        set tag $argv[1]
    end

    set table "title;summary;tags"

    cheat -lt $tag | tail -n +2 | while read -l title path tags
        set tags (string trim -- $tags)

        set summary (
            awk '
                BEGIN { in_yaml=0 }
                /^---$/ { in_yaml = !in_yaml; next }
                in_yaml { next }
                /^#/ { sub(/^# /, ""); print; exit }
            ' $path ^/dev/null | string trim
        )

        set -a table "$title;$summary;$tags"
    end

    printf "%s\n" $table | column -t -s ";"
end

This gives me output like:

title            summary                                           tags
br               alias to broot, explores folders                 personal
cargo-audit      Audit for vulnerable crates                      personal,rust
cargo-edit       Add a dependency to Cargo.toml                  personal,rust

The summary is extracted from the first heading (# ...) after any front matter in the cheat file. This feature makes cheat much more usable for me. It presents me with a quick list of my most used commands along with a summary of what each one does. That way I don't have to call cheat on each command individually to figure out which one I actually want.

πŸ’‘ Feature Suggestion

It would be fantastic to have this built in as an official feature β€” something like:

cheat -l -S
# or
cheat -l --summary
# or to list personal cheat sheets with summaries
cheat -Slt personal

This could extract the summary the same way (first heading after YAML front matter) and display it alongside the sheet title and tags.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions