Skip to content

Manage your self-defined cheat sheets & knowledge base in Alfred

License

Notifications You must be signed in to change notification settings

odapg/alfred-cheat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alfred-cheat

This workflow is based on wx-Yao's original Alfred-cheat. It adds a few features, in particular a quicklook view.

It relies on deanishe's Alfred-Workflow, and was initally inspired by cheat.

The moto is: write your own cheat sheets very simply and make them searchable using Alfred!


Download via release

Demo

Demo...

How it works

  1. Define a directory to store your cheatsheets.
  2. Write your cheatsheet according to the very simple rule described below or download cheatsheet from cheatsheet,1 and put them in that directory.
  3. Tell the workflow where that directory is.

Usage

  • First, specify your cheatsheets directory (once for all) by using

    cf <cheatsheet_folder>

    You can use absolute or relative path to specify <cheatsheet_folder>.

Then, you're good to go:

  • To list all your cheatsheets: cht

  • To search and list the content of one of your cheatsheet: cht <sheet_name>. Fuzzy search and autocomplete is supported (thanks to deanishe).

  • To search in a specific sheet indexed by some keyword:

    cht <sheet_name> <keyword>.

  • To search across all your sheets for some keyword:

    cht --search <keyword>

  • You can paste the selected record directly to the app you're using (e.g., Terminal) by hitting .

  • If you like to just copy, hit ⌘C.

New!

  • Open your cheatsheet file in your text editor by hitting ⌘↵.2

  • See an item in large type by hitting ⌘L.

  • Open a quicklook view of your selection by either hitting or ⌘Y.

Remark. I changed wx-Yao's cheat keyword into cht because I find it quicker. But you can easily reverse this change.

Parsing rule

The basic rule is very simple:

  1. First the comment (preceded by #), then the command.

  2. Separate each comment, command pair with 2 newlines (one newline visually).

Here is an example.

# This is a one line comment. 
Command one goes here.

# This is a second comment for the second command
# Yes we can have multiple line comment.
Command 2 goes here
And now you can also have two commands!

You can have commands without comments

# but no comments without command -- this is ignored

And remember to separate blocks by 2 newlines (1 visually)!

The above sheet will be parsed like this:

demosheet

New!

  • You can add hidden blocks in your file that will not appear in Alfred nor in the Quicklook view: simply begin the block by /*(no need to close the block)
  • You can add sections that will not appear in Alfred but that will appear in the Quicklook view. Begin the block by //.

Example.

/* This is the beginning of my Alfred cheatsheet.
You can put unicode characters such as ⌘ or ⌥ without problem.

// Basic hotkeys 

#Open file or application in default application 
⌘ o

#Search the currently typed query in Spotlight 
⌥ ↩

#Search the currently typed query in default web search
⌃ ↩

#Reveal in Finder (if the result is a local file) 
⌘ ↩

// Files and applications

#Navigate to your home folder
~

This will give the following result in Quicklook.

Quicklook example

Remark. Hidden cheatsheets (starting with .) as well as hidden directories are ignored. Hierachical structure is supported but that's only for your management purpose. This tool only "flattens" the hierarchy in the base directory. i.e., cheat/somedir/otherdir/somecheat will be equivalent to cheat/somecheat in its perspective. Also make sure you don't have duplicated cheatsheets in different directories otherwise only one of them will be dominant.

Compatibility

This workflow works without dependencies. It has been tested on macOS 14.2.1 Sonoma with Alfred 5. Of course, you need the powerpack to get it working. It has not been tested on other systems. Report an issue if there's a problem.

Acknowledgement

Porting to Python3 was made by adapting changes to the original workflow due to @giovannicoppola.

Contribution

Any idea of improvement is welcome. As for wx-Yao's original Alfred-cheat, I do not wish to add the feature of modifying cheatsheet right in Alfred because opening it in your text editor is much simpler and efficient.


1: These may sometines need very small adjustments 2: You can specify your favorite text editor in the Alfred-Cheat preferences in Alfred.

About

Manage your self-defined cheat sheets & knowledge base in Alfred

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.5%
  • CSS 0.5%