Skip to main content
Calm Code

Fixing Firefox Email Shortcut with Hammerspoon

Hammerspoon is a small macOS automation tool. You can write Lua code blocks that can handle keyboard events and more.

Firefox used to have a File > Email Link menu that you could assign a shortcut in macOS keyboard shortcuts.

One fine day Firefox or macOS moved this under File > Share > Mail. That breaks my shortcut 😑.

Firefox share menu

I would have updated my shortcut but macOS Big Sur can't assign shortcuts to nested menus 🥲. I really wanted that shortcut back because I use it a lot to email web pages. So I turned to Hammerspoon and hacked together this script.

-- Email the current page 
hs.hotkey.bind({"cmd", "shift"}, "I", function()
  firefox = hs.appfinder.appFromName("Firefox")
  firefox:selectMenuItem({"File", "Share", "Mail"})
end)

This adds a global shortcut Command + Shift + I to trigger that menu 🥳.

Since you are already here let me share another one I use regularly.

-- paste as keystrokes
hs.hotkey.bind({"cmd", "shift"}, "V", function() 
    hs.eventtap.keyStrokes(hs.pasteboard.getContents()) 
end)

With that Command + Shift + V pastes plain text by typing keystrokes. This also bypasses some smart websites that don't let you paste your password 😉.

Check out Hammerspoon and Lua. Maybe you can fix or automate something that annoys you.