fzf-alfred-workflow
fzf-alfred-workflow copied to clipboard
An Alfred workflow fo fuzzy find files/directories using fzf and fd.
fzf-alfred-workflow
An Alfred workflow fo fuzzy find files/directories using fzf and fd.
Features
- โก๏ธ 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 lator.
Change Log
- 1.6.2: Notification on first run after macos startup
- 1.5.3:
fzfandfddetection improved - 1.5.2:
fzf-historyandfzf-edit-historycommands 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-modulehotkey 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
-fand-d, respectively (in addition to^fand^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
Installation
There are two ways to install this workflow:
- Automatic Installation via Alfred Gallery
- Manual Installation (see below)
Downloads
Current Version: 1.6.1
Dependencies
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
Setting Up
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 Multiple paths may be specified in "Search path(s)" separated by semicolons. If a home directory is specified,
~/Librarywill be ignored for better performance; to search within a cloud storage folder such as Dropbox or OneDrive, specify~/Library/CloudStorage/. (e.g.~; ~/Library/CloudStorage/)
File/Directory Search
Fallback search
Setup: Features โ Default Results โ Setup fallback results โ Add Workflow Trigger "FZF Search"
Type in search keys and select "FZF Search"
Folder action
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.
Using keyword
Type in fzf and enter search keys
Using user-specified hotkey
Setup: Features โ Workflows โ fzf-alfred-workflow โ Double click "fzf workflow activation hotkey"
Press the hotkey specified and type enter search keys
Repeated Directory Change
fzf-cd hotkey
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.
List and Edit Search History
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).
Using keyword
The fzf-history command reads this file and allows you to select one of your previous searches and repeat it.
Using user-specified hotkey
Setup: Features โ Workflows โ fzf-alfred-workflow โ Double click "fzf history search hotkey".
Editing Search History
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".
Example Usage
Suppose you have an mp3 music folder and Metallica's Master of Puppets album in it, just for instance.
File/Directory Search
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
File Only Search
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
Directory Only Search
Use ^d or -d directive to search directories only.
fzf metallica puppets ^d
/music/metallica/master-of-puppets/
Acknowledgments
The icon of this workflow
is used under Simplified Pixabay License
Author
Yoichiro Hasebe ([email protected])
License
The MIT License
Disclaimer
The author of this software takes no responsibility for any damage that may result from using it.