Rapid App Switching with Hammerspoon

Faster Faster

The key to learning things faster is to reduce the feedback cycle. When it comes to developing with new technologies, you want to be able to iterate quickly and that means delegating as much as possible to patterns, templates, shortcuts.

With simple bash scripting you can quickly scaffold web projects, open relevant apps and be ready for dev. But the one minor niggle I’ve had is that I would have to manually arrange all the open windows myself.

I was using Betternsap tool and divvy but would have to still get focus of each individual window and specify where to put it each time. So needed a hackable window manager. Enter hammer time, or Hammerspoon.

Hammerspoon is a hackable window manager. It allows you to do everything that I could do with BetterSnapTool befor, plus more.

Fast Reload

We’re going to want a fast way to reload our config changes so we can preview them straight away. Enter the following function at the top of the init.lua

hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function()
	hs.reload()
	hs.alert.show("Config loaded")
	end
)

I like to have google chrome, sublime and terminal laid out in the following way but you can edit this to your own liking.

You can create keyboard shortcuts to individual apps so that they are just a click away. This has become second nature to me now so I can switch applications instantly without using the mouse, exposé, or alt+tabbing around. For example to launch Mail.app I use:

hs.hotkey.bind({"ctrl"}, "m", function()
  hs.application.launchOrFocus("Mail")
end)
source