Hammerspoon Spoon that intercepts http and https URL events and lets you choose which browser opens each link.
When a web link is opened, URLPicker shows a compact picker near the mouse cursor with installed browser handlers. Select a browser with the mouse, arrow keys and Return, or dismiss the picker with Escape.
- Hammerspoon
- macOS URL handler permissions for Hammerspoon
- One or more installed applications registered as handlers for
http/httpsURLs
Copy or symlink this folder to:
~/.hammerspoon/Spoons/URLPicker.spoon/
Or distribute it as URLPicker.spoon.zip; after unzipping, double-click the .spoon bundle to install it with Hammerspoon.
In your Hammerspoon init.lua:
hs.loadSpoon("URLPicker")
spoon.URLPicker:start()By default, start() sets Hammerspoon as the system handler for http and https links so URLPicker can receive link-open events.
Configure public properties before calling start() or pass a table to start():
hs.loadSpoon("URLPicker")
spoon.URLPicker.pinnedBrowsers = {
"org.mozilla.firefox",
"com.google.Chrome",
}
spoon.URLPicker:start({
autoSetDefaultHandlers = true,
restoreDefaultHandlersOnStop = false,
maxCandidates = 24,
})You can also configure without starting:
spoon.URLPicker:configure({
pinnedBrowsers = { "org.mozilla.firefox" },
maxCandidates = 12,
})Pinned browsers are configured with macOS bundle IDs. Useful examples include:
- Firefox:
org.mozilla.firefox - Google Chrome:
com.google.Chrome - Chromium:
org.chromium.Chromium - Safari:
com.apple.Safari - Microsoft Edge:
com.microsoft.edgemac - Brave Browser:
com.brave.Browser
Only installed apps that are registered handlers for the URL scheme are shown.
start()installs anhs.urlevent.httpCallbackand optionally sets Hammerspoon as the defaulthttp/httpshandler.- When a supported URL arrives, the Spoon lists installed URL handlers for that scheme.
- Pinned browsers are shown first, followed by the remaining handlers alphabetically.
- Selecting a browser opens the URL with
hs.urlevent.openURLWithBundle(). stop()closes the picker and restores the previoushs.urlevent.httpCallback. It restores previous system URL handlers only whenrestoreDefaultHandlersOnStopis true.
Public API is documented in Hammerspoon docstring format in init.lua and collected in docs.json.
Main methods:
URLPicker:start([config])— start URL interception.URLPicker:stop()— stop URL interception.URLPicker:configure(config)— apply configuration without starting.URLPicker:show(url)— show the picker manually for anhttp/httpsURL.URLPicker:enable()— set Hammerspoon as defaulthttp/httpshandler.URLPicker:disable()— restore previously captured default handlers.URLPicker:cleanup()— close the picker UI and stop temporary event taps.
Public properties:
URLPicker.configURLPicker.pinnedBrowsersURLPicker.logger
MIT — see https://opensource.org/licenses/MIT.