For some reason, including /opt/homebrew/Cellar
(the path to Homebrew's Cellar on Apple Silicon devices) in Alfred's Search Scope doesn't work, at least for Emacs.
But I found a more generic solution that should work for any application. The trick is to create an alias in /Applications
to the application's .app
dir/bundle, and then to tell Alfred to include macOS aliases in search results.
I use Homebrew-installed Emacs as an example below because generalizing the instructions would make the language awkward. Extending the example ought to be trivial.
First, create a macOS alias (not a symlink):
- In Finder, press Cmd+Shift+G and use Tab auto-complete to enter the path of the directory containing "Emacs.app" (In my case, this is currently
/opt/homebrew/Cellar/emacs-mac/emacs-27.2-mac-8.3
)
- Press Cmd+N to open a new Finder window, then Cmd+Shift+A to go to
/Applications
- Create the alias by Cmd+Opt dragging "Emacs.app" from the homebrew window to the
/Applications
window.
Now, let's make Alfred include macOS aliases in search results:
- Open Alfred's preferences (alfred 4.7), navigate to Features > Default Results click Advanced.... A popup window will open that allows you to add file types that will be shown in search results.
- Drag the
Emacs.app
alias from the Finder /Applications
window to the popup window. The new entry should read com.apple.alias-file | alias
- Close the popup and try searching for 'emacs'. The result list should include the "Emacs.app" alias.
The alias will fail at every update that changes the versioned path to the app in the Cellar, which happens to be emacs-27.2-mac-8.3
at writing. The correct solution to the underlying problem is to fix Alfred so it picks up applications installed to /opt
. A hacky alternative might be to hook into homebrew
and recreate the alias when needed.
I'll probably manually recreate the alias each time it breaks so that the breakage can serve as a reminder to check for an upstream fix to the underlying problem.