I am on an eternal quest to optimize the way I work with the computer.

I do things like jacking my mouse/tracking speed all of the way up (thanks Noah). I am trying to use Zapier more because “you should never do something twice on a computer” (thanks Nat). I do things like disable animations and constantly am trying to find new and better ways to speed up my computing life.

My latest quest has been to figure out how to speed up switching between running applications.

Cmd + Tab / Alt + Tab is great but it leaves a ton to be desired. On OS X, windows are grouped by application and you have to use Cmd + ` to cycle through the windows of a running app. There are third-party apps to accomplish the Windows-like functionality but I felt there there much be a better way. I also am pretty notorious for going past the app I want to switch to and end up having to go through all of my open apps or adjusting my grip to include Shift to go back. It’s never been ideal for me.

My buddy Justin recently introduced me to Hammerspoon. Hammerspoon allows you to create hotkeys that interact with fairly low level operating system functions. He’s using this to create advanced / scriptable windows layouts. Not something I need, but what if I could use this to create a better way for me to switch between apps?

If you’re like me, you have a handful of apps that you use constantly. There’s also a good chance that you have your dock arranged in a very specific way based on which apps you use the most often. I’ve sworn off the dock because I find it inefficient (more on that in another post) but I still have my “favorite” apps.

This got me thinking about Doom, Quake and many other first-person shooting games. No, I wasn’t side tracked. I just got to thinking about the HUD and how you switched weapons. Every weapon had it‘s own number and it was very easy to switch between them.

Obviously it doesn’t make sense to assign apps keys to individual keys, but what if I could setup a series of hotkey in Hammerspoon that utilized the numbers to switch between my most used apps? Crazy enough to work, if you ask me!

What I ended up doing was mapping Cmd + Ctrl + # (1-3) to allow for fast switching between my top 3 apps. My init.lua looks like this for one of the apps:

hs.hotkey.bind({"cmd", "ctrl"}, "1", function()
  hs.application.launchOrFocus("Terminal")
end)

It’s not the most ideal hotkey, but it’s been working out great. My top three apps are 1. Terminal, 2. Google Chrome and 3. Slack.

I am working on improving the hotkey by using Karabiner to allow me to target the Right Option key so I can reduce the hotkey down to just Right Opt

  • #. I’ll follow up once I have that worked out :)

I still have a ways to go to break the Cmd + Tab muscle memory but thus far, the new hotkeys have been an extremely efficient way to quickly switch between my most frequented apps.