An Alfred workflow fo fuzzy find files/directories using fzf and fd.
- ⚡️ Fuzzy Search: You can enter search keys that partially match file/directory paths in any order.
- 🧠 Memorization: Alfred manages the order of items according to past usage.
- 🗂 Folder Action: Search directory can be set in user preferences or specified dynamically in a folder action.
- 📝 Editable Search History: Search history is automatically recorded and can be edited later.
Change Log
- 1.6.2: Notification on first run after macos startup
- 1.5.3:
fzf
andfd
detection improved - 1.5.2:
fzf-history
andfzf-edit-history
commands added - 1.4.0: Better performance; Alfred Gallery](https://alfred.app/workflows/yohasebe/fzf/) inclusion
- 1.3.2: fzf and fd installation is automatically detected
- 1.3.1:
fzf-cd-module
hotkey feature added (thanks to pSpitzner) - 1.3.0: check-for-update has been removed (in preparation for application to Alfred Gallery)
- 1.2.2: check-for-update command has been added
- 1.1.1: File and directory searches can be set with
-f
and-d
, respectively (in addition to^f
and^d
). - 1.1.0: Memorize order option (
memorize
) is added and set default totrue
- 1.0.2: Search path option (
search_path
) is set default to~
(home directory) - 1.0.1: User configuration made available for Alfred 5
There are two ways to install this workflow:
- Automatic Installation via Alfred Gallery
- Manual Installation (see below)
Current Version: 1.6.2
Installation of fzf
and fd
is only required if the workflow is installed manually.
- Alfred Powerpack
- fzf: a general-purpose command-line fuzzy finder
- fd: a simple, fast and user-friendly alternative to find
Using homebrew:
brew install fzf
brew install fd
Set values to the following options in User Configuration
(Alfred 5):
Setting | Explanation |
---|---|
Num of candidates | Number of candidate files/directories shown in Alfred (default: 100) |
Search path(s) | Directory from which recursive fzf searches are conducted (default: ~ ) * |
Memorize order | If checked or set true , Alfred will manage the order of items according to usage |
Max Num of Past Searches | Maximum number of past search history retained (default: 1000 |
* Search directory can be also specified dynamically in a folder action.
Note 1
Multiple paths may be specified in "Search path(s)" separated by semicolons. If a home directory is specified,~/Library
will be ignored for better performance; to search within a cloud storage folder such as Dropbox or OneDrive, specify~/Library/CloudStorage/
. (e.g.~; ~/Library/CloudStorage/
)
Note 2
If changes to “Search path(s)” do not take effect, restarting your Mac may resolve the issue.
Setup: Features → Default Results → Setup fallback results → Add Workflow Trigger "FZF Search"
Type in search keys and select "FZF Search"
Setup: Features → Universal Actions → Actions → Check Workflow File Actions
Select a folder in the Finder and launch File Action "FZF Search from Here". The selected folder will be the search path that temporarily overrides the search path specified in the user settings.
Type in fzf
and enter search keys
Setup: Features → Workflows → fzf-alfred-workflow → Double click "fzf workflow activation hotkey"
Press the hotkey specified and type enter search keys
Setup: Features → Workflows → fzf-alfred-workflow → Double click "fzf-cd hotkey"
Select a folder in a Finder window or Alfred folder browser. Then press the hotkey. You can do this repeatedly until you finally reach the target file or directory.
Thanks to Paul Spitzner for suggesting this.
The search key is automatically recorded in a file name (fzf-search-history.txt
) in the workflow data directory (only if more than one search result is found).
The fzf-history
command reads this file and allows you to select one of your previous searches and repeat it.
Setup: Features → Workflows → fzf-alfred-workflow → Double click "fzf history search hotkey".
The fzf-edit-history command sends the path to the history file to Alfred, allowing you to edit it in the app of your choice. The history file contains lines of text, each consisting of the date and time of a past search, followed by the search key separated by a single vertical line (|).
Example: 2023-05-13 20:14:51 +0900 | search string
Hotkey Setup: Features → Workflows → fzf-alfred-workflow → Double click "fzf history edit hotkey".
Suppose you have an mp3 music folder and Metallica's Master of Puppets album in it, just for instance.
fzf metallica puppets
The above will fetch you both files and directories. The order of search keys (metallica
and puppets
) does not matter.
/music/metallica/master-of-puppets/
/music/metallica/master-of-puppets/01-battery.mp3
/music/metallica/master-of-puppets/02-master-of-puppets.mp3
/music/metallica/master-of-puppets/03-the-thing-that-should-not-be.mp3
/music/metallica/master-of-puppets/04-welcome-home.mp3
/music/metallica/master-of-puppets/05-disposable-heroes.mp3
/music/metallica/master-of-puppets/06-leper-messiah.mp3
/music/metallica/master-of-puppets/07-orion.mp3
/music/metallica/master-of-puppets/08-damage-inc.mp3
You can narrow them down by adding search keys. Again, the order of search keys does not matter.
fzf metallica puppets damage
/music/metallica/master-of-puppets/08-damage-inc.mp3
Use ^f
or -f
directive to search files only.
fzf metallica puppets ^f
/music/metallica/master-of-puppets/01-battery.mp3
/music/metallica/master-of-puppets/02-master-of-puppets.mp3
/music/metallica/master-of-puppets/03-the-thing-that-should-not-be.mp3
/music/metallica/master-of-puppets/04-welcome-home.mp3
/music/metallica/master-of-puppets/05-disposable-heroes.mp3
/music/metallica/master-of-puppets/06-leper-messiah.mp3
/music/metallica/master-of-puppets/07-orion.mp3
/music/metallica/master-of-puppets/08-damage-inc.mp3
Use ^d
or -d
directive to search directories only.
fzf metallica puppets ^d
/music/metallica/master-of-puppets/
The icon of this workflow is used under Simplified Pixabay License
Yoichiro Hasebe (yohasebe@gmail.com)
The MIT License
The author of this software takes no responsibility for any damage that may result from using it.