If you are a Mac user you and consider yourself a power user you know about CMD + Space
to open the Spotlight search bar. This is a very powerful too. It has serveral uses. I guess what we users most use it for is to start applications with your keyboard. You just start typinge the applications names, saf...
and it will show you Safari and simply press enter. That's really great. You can launch almost any app with 5 keystrokes on your mac using spotlight, CMD
, Space
, s
,a
,f
.
However, it could be better, how about just 2 keystrokes? This is where Hammerspoon can help us. I'm a big fan of Hammerspoon and it has infinite use cases. It's an open source software which could make your live as an Apple User way more productive.
One heavy use for me out of Hammerspoon is the ability to assign applications to keystrokes, for example I simply press Alt + S
to start Safari, Alt + F
to open the finder and Alt + K
to open my companies messenger. It's great and I have many more. The beauty is there are still a lot of these convenient key combinations available for you to assign. It will become second nature like CMD + S
for saving or CMD + F
for searching. Just check yourself, what Alt + Any Character
acutally does. Often it's just a special form of that character. Alt + F
for example produces ƒ
for me. Looks cool though, but i'm not in a frequent need of that. Happier to open up Finder with this key combination.
So how to do it? It might be a bit long for an in depth introduction to Hammerspoon. But basically with Hammerspoon exposes system level APIs to a Lua Environment. No worries, I'm also not fluent in Lua, it's not too bad. Here is the code I use to assign using the hotkey
API.
hs.hotkey.bind(
{"alt"},
"s",
function()
hs.application.open("safari")
end
)
See, it’s quite short and straight forward. The first parameter is the modifier key, the second the additonal key you want to press together with the modifier and the final parameter for this bind()
function is another function to execute itself. This can be as shown here an anonymous function which hasn’t been declared before. This function to be executed uses the appplication
api to open the safari app. Both of these APIs are straightforward and are quite powerfull in conjuction.
This is one of the most common uses cases I use Hammerspoon for and until now I haven’t found a more elegant way to do this on a Mac. Hammerspoon itself offers way more and is quite an awesome tool. It’s open source and free to use and big bonus it does not have a system tray icon (I hate those), it’s ultra quite and I haven’t had any issues with it in my several years using it. It gets updated frequently and even after a major Mac OS update it’s updated quite quickly to work with the new version. Highly highly recommened Hammerspoon and this hotkey API to open apps.
Here’s a list of mine for you to get inspired by
Alt + C : Chrome
Alt + S : Safari
Alt + F : Finder
Alt + E : Editor
Alt + O : Note Taking App
Alt + K : Messenger
Alt + , : Calendar
Alt + M : Accounting App