There are a lot of articles and videos out there with best apps for macOS, etc., and the one I am mentioning in this article is fairly well known (I think!), but still I want to give it some credit because it’s an amazing tool, it simplified some important things for me and it deserves the recognition.
The app I am talking about is Hammerspoon.
Why Hammerspoon Deserves Your Attention
If you go to its website and start reading about it you might get intimidated a bit from seeing all that code, technical documentation and what seems to be a convoluted set up process, but it’s actually quite easy and the initial small effort to set it up is well worth it.
Instead of juggling multiple apps for window management, keyboard shortcuts, and system automation, Hammerspoon handles everything through simple configuration files and can replace apps like Rectangle, Keyboard Cowboy and many others. Find below a quick explanation of how to set it up.
My Two Game-Changing Use Cases
1. Window Management
Forget Rectangle, Magnet, or any other window manager you’re paying for. Hammerspoon’s Miro Windows Manager gives you complete control over window positioning with intuitive keyboard shortcuts.
The code is public, you just have to connect it to your init.lua in .hammerspoon folder.
As the author, Miro Mannino, says:
With this script you will be able to move the window in halves and in corners using your keyboard and mainly using arrows. You would also be able to resize them by thirds, quarters, or halves.
After installing the Miro Windows Manager Spoon, I use these shortcuts constantly:
- Ctrl + Option + Cmd + Arrow Keys: Snap windows to halves and corners instantly
- Ctrl + Option + Cmd + Up + Down arrow: Maximize window height while maintaining width
- Ctrl + Option + Cmd + N: Move windows between external displays
- Ctrl + Option + Cmd + F: Make the window take up full width and height
These three modifier keys sit right next to each other, making the shortcuts impossible to forget, at least on my keyboard.
2. Visual Focus Indicator
Here’s a problem you didn’t know you had perhaps: Which window is actually active right now?
It sounds trivial until you realize how often you hit the wrong keyboard shortcut because you thought a different app was focused. The solution: a subtle red border that follows your active window.
This simple visual cue has made me noticeably faster at navigating between apps. I always know exactly which keyboard shortcuts are available because I can see at a glance which app has focus.
In combination with the native app switcher (CMD + TAB) or Spotlight search it saves me lots of time. Just imagine.
Getting Started (It’s Easier Than You Think)
Step 1: Installation and Setup
- Download Hammerspoon from hammerspoon.org
- Navigate to your home directory:
~/Users/[your-name]/ - Press
Cmd + Shift + .to reveal hidden folders - Look for the
.hammerspoonfolder (it appears after installation) - Open the folder in VSCode and add Spoons and configurations in
init.luafile — this is your configuration hub
Step 2: Adding Window Management
Visit the Spoons page or browse community configurations on GitHub to pick other solution you like. I chose Miro Windows Manager. Simply copy the configuration into your hammerspoon folder and follow the indications from GitHub.
Step 3: The Red Border Focus Indicator
Save this code as redFrame.lua in your .hammerspoon folder:
-- redFrame.lua
-- Window border highlighting module for Hammerspoon
local redFrame = {}
local global_border = nil
local allwindows = nil
-- Draw a red border around the focused window
function redFrame.redrawBorder()
local win = hs.window.focusedWindow()
if win ~= nil then
local top_left = win:topLeft()
local size = win:size()
if global_border ~= nil then
global_border:delete()
end
global_border = hs.drawing.rectangle(hs.geometry.rect(top_left['x'], top_left['y'], size['w'], size['h']))
global_border:setStrokeColor({["red"]=1,["blue"]=0,["green"]=0,["alpha"]=0.8})
global_border:setFill(false)
global_border:setStrokeWidth(8)
global_border:show()
end
end
-- Initialize the module
function redFrame.init()
-- Draw initial border
redFrame.redrawBorder()
-- Set up window filter to track window events
allwindows = hs.window.filter.new(nil)
allwindows:subscribe(hs.window.filter.windowCreated, function() redFrame.redrawBorder() end)
allwindows:subscribe(hs.window.filter.windowFocused, function() redFrame.redrawBorder() end)
allwindows:subscribe(hs.window.filter.windowMoved, function() redFrame.redrawBorder() end)
allwindows:subscribe(hs.window.filter.windowUnfocused, function() redFrame.redrawBorder() end)
end
-- Clean up function (optional)
function redFrame.stop()
if global_border ~= nil then
global_border:delete()
global_border = nil
end
if allwindows ~= nil then
allwindows:unsubscribeAll()
allwindows = nil
end
end
-- Return the module table
return redFrame
Then add these lines to your main init.lua:
local redFrame = require('redFrame')
-- other configurations...
redFrame.init()
Step 4: Activate Your Configuration
Click “Reload Config” from the Hammerspoon menu bar icon. If all is good, you’ll immediately see the red border around your active window and the keyboard shortcuts for window management should work. Now, the red border around the active window is sometimes glitchy but it works just fine most of the time, for me it’s a trade I’m willing to make.
The Bottom Line
Hammerspoon isn’t just another Mac app — it’s something different, better. It allows you customization capabilities for various use cases and I like the fact that I can achieve with one app what could be achieved with many apps and it’s totally free and you can harness the power of a community.
Yes, there’s a small learning curve, or a bigger one depending on how deep you want to go, and you can go pretty deep on it. But once you experience the benefits of these “hacks”, you’ll wonder how you ever used your macOS without it.
I recommend you start with these two simple configurations. Once you get the taste of it, you can search and discover countless other ways to automate and customize your workflows. The community is active, with solutions for almost any workflow challenge you can imagine and there’s also a Discord server.
Your Mac is capable of so much more automation than you realize. Hammerspoon is a great tool to unlock its potential in this direction.
This is the way!