All Projects → deanishe → Alfred Fuzzy

deanishe / Alfred Fuzzy

Licence: mit
Fuzzy search helper for Alfred 3+ workflows

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Alfred Fuzzy

Awgo
Go library for Alfred 3 + 4 workflows
Stars: ✭ 556 (+729.85%)
Mutual labels:  alfred, alfred-workflow, fuzzy-search, fuzzy
Alfred Workflow
Full-featured library for writing Alfred 3 & 4 workflows
Stars: ✭ 2,622 (+3813.43%)
Mutual labels:  alfred, alfred-workflow, fuzzy-search
Alfred Mdi
Alfred 3 workflow to find Material Design Icons
Stars: ✭ 38 (-43.28%)
Mutual labels:  alfred, alfred-workflow
Whyliam.workflows.youdao
使用有道翻译你想知道的单词和语句
Stars: ✭ 837 (+1149.25%)
Mutual labels:  alfred, alfred-workflow
Alfred Lock
Alfred 3 workflow to lock your Mac
Stars: ✭ 54 (-19.4%)
Mutual labels:  alfred, alfred-workflow
Alfred Appscripts
Alfred workflow to search and run/open AppleScripts for the active application
Stars: ✭ 56 (-16.42%)
Mutual labels:  alfred, alfred-workflow
Alfred Spotify Mini Player
🎵🎩 Alfred workflow to control your Spotify library at your fingertips
Stars: ✭ 823 (+1128.36%)
Mutual labels:  alfred, alfred-workflow
Fuzzy
Go library that provides fuzzy string matching optimized for filenames and code symbols in the style of Sublime Text, VSCode, IntelliJ IDEA et al.
Stars: ✭ 979 (+1361.19%)
Mutual labels:  fuzzy-search, fuzzy
Alfred Font Awesome Workflow
🎩 Font Awesome workflow for Alfred
Stars: ✭ 714 (+965.67%)
Mutual labels:  alfred, alfred-workflow
Alfred Kozip Workflow
📦 도로명/지번 한영 주소 검색을 Alfred에서!
Stars: ✭ 21 (-68.66%)
Mutual labels:  alfred, alfred-workflow
Alfred Man
man(1) workflow for Alfred
Stars: ✭ 21 (-68.66%)
Mutual labels:  alfred, alfred-workflow
Alfred Bluetooth Connect
Alfred plugin that allowed to connect/disconnect to paired bluetooth device
Stars: ✭ 28 (-58.21%)
Mutual labels:  alfred, alfred-workflow
Alfred Atom
Alfred workflow to browse and open Atom projects
Stars: ✭ 41 (-38.81%)
Mutual labels:  alfred, alfred-workflow
Wechat Alfred Workflow
wechat workflow for Alfred:微信快速发送消息 & 打开聊天窗口 & 查看聊天记录 & more…
Stars: ✭ 822 (+1126.87%)
Mutual labels:  alfred, alfred-workflow
Alfred Unicode
Preview Unicode characters and emoji in Alfred
Stars: ✭ 23 (-65.67%)
Mutual labels:  alfred, alfred-workflow
Alfred Collection
A collection of all known Alfred3 workflows
Stars: ✭ 785 (+1071.64%)
Mutual labels:  alfred, alfred-workflow
Flexsearch
Next-Generation full text search library for Browser and Node.js
Stars: ✭ 8,108 (+12001.49%)
Mutual labels:  fuzzy-search, fuzzy
Play Song
An Alfred workflow for quickly and easily playing music in iTunes / Apple Music
Stars: ✭ 62 (-7.46%)
Mutual labels:  alfred, alfred-workflow
Alfred Workflows
Workflows for Alfred
Stars: ✭ 577 (+761.19%)
Mutual labels:  alfred, alfred-workflow
Wechattweak Macos
A dynamic library tweak for WeChat macOS - 首款微信 macOS 客户端撤回拦截与多开
Stars: ✭ 6,505 (+9608.96%)
Mutual labels:  alfred, alfred-workflow

Fuzzy search for Alfred

fuzzy.py is a helper script for Alfred 3+ Script Filters that replaces the "Alfred filters results" option with fuzzy search (Alfred uses "word starts with").

How it works

Instead of calling your script directly, you call it via fuzzy.py, which caches your script's output for the duration of the user session (as long as the user is using your workflow), and filters the items emitted by your script against the user's query using a fuzzy algorithm.

The query is compared to each item's match field if it's present, and against the item's title field if not.

Example usage

fuzzy.py only works in Script Filters, and you should run it as a bash/zsh script (i.e. with Language = /bin/bash or Language = /bin/zsh).

Instead of running your own script directly, place ./fuzzy.py in front of it.

For example, if your Script Filter script looks like this:

/usr/bin/python myscript.py

You would replace it with:

# Export user query to `query` environment variable, so `fuzzy.py` can read it
export query="$1"
# Or if you're using "with input as {query}"
# export query="{query}"

# call your original script via `fuzzy.py`
./fuzzy.py /usr/bin/python myscript.py

Note: Don't forget to turn off "Alfred filters results"!

Demo

Grab the Fuzzy-Demo.alfredworkflow file from this repo to try out the search and view an example implementation.

Caveats

Fuzzy search, and this implementation in particular, are by no means the "search algorithm to end all algorithms".

Performance

By dint of being written in Python and using a more complex algorithm, fuzzy.py can only comfortably handle a small fraction of the number of results that Alfred's native search can. On my 2012 MBA, it becomes noticeably, but not annoyingly, sluggish at about ~2500 items.

If the script is well-received, I'll reimplement it in a compiled language. My Go library for Alfred workflows uses the same algorithm, and can comfortably handle 20K+ items.

Utility

Fuzzy search is awesome for some datasets, but fairly sucks for others. It can work very, very well when you only want to search one field, such as name/title or filename/filepath, but it tends to provide sub-optimal results when searching across multiple fields, especially keywords/tags.

In such cases, you'll usually get better results from a word-based search.

Technical details

The fuzzy algorithm is taken from this gist by @menzenski, which is based on Forrest Smith's reverse engineering of Sublime Text's algorithm.

The only addition is smarter handling of non-ASCII. If the user's query contains only ASCII, the search is diacritic-insensitive. If the query contains non-ASCII, the search considers diacritics.

Customisation

You can tweak the algorithm by altering the bonuses and penalties applied, or changing the characters treated as separators.

Export different values for the following environment variables before calling fuzzy.py to configure the fuzzy algorithm:

Variable Default Description
adj_bonus 5 Bonus for adjacent matches
camel_bonus 10 Bonus if match is uppercase
sep_bonus 10 Bonus if after a separator
unmatched_penalty -1 Penalty for each unmatched character
lead_penalty -3 Penalty for each character before first match
max_lead_penalty -9 Maximum total lead_penalty
separators _-.([/ Characters to consider separators (for the purposes of assigning sep_bonus)

Multiple Script Filters

If you're using multiple Script Filters chained together that use different datasets, you'll need to set the session_var environment variable to ensure each one uses a separate cache:

# Script Filter 1
export query="$1"
./fuzzy /usr/bin/python myscript.py

# Script Filter 2 (downstream of 1)
export query="$1"
export session_var="fuzzy_filter2"
./fuzzy /usr/bin/python myotherscript.py

Thanks

The fuzzy matching code was (mostly) written by @menzenski and the algorithm was designed by @forrestthewoods.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].