Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wayneyaoo/alfred-cheat
Manage your self-defined cheat sheets & knowledge base in Alfred
https://github.com/wayneyaoo/alfred-cheat
alfred alfred3-workflow alfred4 cheatsheet command-line productivity
Last synced: 6 days ago
JSON representation
Manage your self-defined cheat sheets & knowledge base in Alfred
- Host: GitHub
- URL: https://github.com/wayneyaoo/alfred-cheat
- Owner: wayneyaoo
- License: mit
- Created: 2019-07-08T05:29:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-25T17:48:08.000Z (11 months ago)
- Last Synced: 2024-08-02T16:03:49.414Z (3 months ago)
- Topics: alfred, alfred3-workflow, alfred4, cheatsheet, command-line, productivity
- Language: Python
- Homepage:
- Size: 8.24 MB
- Stars: 137
- Watchers: 7
- Forks: 11
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Alfred-cheat ![GitHub All Releases](https://img.shields.io/github/downloads/wayneyaoo/alfred-cheat/total.svg)
**Start writing your very own cheat sheets in your way and make them searchable using Alfred!**# Notice
- Thanks to [@giovannicoppola](https://github.com/giovannicoppola) for porting a [python3 version dependency](https://github.com/NorthIsUp/alfred-workflow-py3) so that this workflow works on macOS >= 12.3 now where default Python version is Python3. Starting from alfred-cheat 1.2.1, the workflow requires Python3 to run, and any version lower than 1.2.1 requires python2. So depending on you macOS version, you migth want to figure out whether you need to install an extra python.
- I'm fully switching to Linux DE for personal tasks and Windows for daily work hence won't be able to put a lot of effort on this workflow. It served me well for a long time. I'm still open to new Pull Request if you think new features should be added. But generally this workflow doesn't have a big scope and should always work.
# Demo
*Every sheet shown in the demo should be your knowledge base and is totally customizable.*
![...loading demo gif](assets/demo.gif)
# About & Acknowledgement
This project was initally inspired by [cheat](https://github.com/cheat/cheat). I attempted to wrap around it but failed because that project wasn't intended to be wrapped around. So this project ended up a separate one. These two projects serve similar purpose in different working environments. With the help of alfred, your efficiency in searching your cheat sheets will be significantly boosted. And the better news is, you're in complete control of your cheat sheets unlike [tldr](https://github.com/tldr-pages/tldr) (It's good though if you want it "just work").
I built this workflow because:
1. I want faster searching than the original [cheat](https://github.com/cheat/cheat) because that project is commandline based. Sometimes I want a very quick view and don't wanna popup a shell.
2. I want to build my own knowledge base instead of community-driven cheat sheets like [tldr](https://github.com/tldr-pages/tldr) does.
**Disclaimer**:
All codes in directory `workflow` are dependencies from [this project](https://github.com/deanishe/alfred-workflow). They're not my work and is the only "dependency" for this project. Since it's included in this repo, the workflow user doesn't have to concern about dependencies.
# Download via [release](https://github.com/wx-Yao/alfred-cheat/releases)
# How it works
1. You define a directory to store your cheat sheets, which are essentially text files. And name the file the command your wanna record. e.g, `nmap`, `top`, `tar` etc. (tips: you can start with the cheat sheets provided by [cheat](https://github.com/cheat/cheat))
2. You write your cheat sheet according to the [rules](#parsing-rule) (very intuitive and tolerant) bit by bit.
3. Tell the workflow where that directory is and start searching.
# Usage
First, you need to specify your sheet directory like this. Otherwise, it doesn't work. Both absolute or relative path will work.
![](assets/config.png)
Then, you're good to go.
- To list all your cheat: `cheat`
- To search and list the content of one of your cheat: `cheat `. Fuzzy search and autocomplete is supported.
- To search in a specific sheet indexed by some keyword: `cheat `.
- To search across all your sheets for some keyword: `cheat --search/-s `
- When you find your desired record and you wanna paste it directly to the app you're using (e.g., Terminal or iTerm2), hit `Enter`. This behavior can be changed in the Alfred setting ([#3](https://github.com/wx-Yao/alfred-cheat/issues/2#issuecomment-509689404)).
- If you like to just copy, hit `cmd-c`.
# Parsing rule
It's not even a rule... You just need to remember two things when writing your cheat sheet:
1. Comment first, then the command.
2. Separate each `comment, command` pair with 2 newlines. (one newline visually)
That's it.
e.g. this cheat sheet is called `demosheet`. Its content is the following:
```
# 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.
# But remember only the last line will be considered "command".
command two goes here#
command three: in rare cases you don't have any comment, keep an empty # above.# Any failed parsing will be ignored, like this line because it isn't associated with a command
or this line because it's a single line.
```The above sheet will be parsed like this:
![](assets/demosheet.png)
Kindly note that **hidden cheatsheets (starting with `.`) will be ignored and hidden directory will be ignored as well**. Hierachical structure is supported but that's only for your management purpose. This tool will only "flatten" every cheatsheets in the base directory. i.e., `cheat/mydir/yourdir/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. Thanks for [@Blackvz](https://github.com/Blackvz) for the feature suggestion [#4](https://github.com/wx-Yao/alfred-cheat/issues/4).
# Compatibility
This workflow works out of the box (zero dependencies). It's tested on **macOS 10.14.5 Mojave** with **Alfred 4**. You need the [powerpack](https://www.alfredapp.com/shop/) to get it working. I believe it works with Alfred3 on any macOS after 10.10 Yosemite but that hasn't been tested. Report an issue if there's a problem.
# Contribution
Any idea of improvement will be welcomed. But I don't wanna add the feature of modifying cheat sheet right in Alfred because it isn't what it is supposed to do. Use vim or other editors you like.