Hammerspoon window management: a working tiling config for your Mac
Hammerspoon is a free, open-source automation tool for the Mac that you script in Lua, and window management is the job most people install it for. Its window tools are some of the most flexible on macOS. You can build your own tiler with one hotkey per half and third, a grid you drive with the keyboard, and "throw it to the other display" in about thirty lines. This guide gives you a Hammerspoon window management config that works as pasted, explains each part, lists the Spoons that save you writing it and ends with an honest look at when a ready-made app like Let's Tile is less work.
Install Hammerspoon and grant Accessibility
- Download it from hammerspoon.org or run
brew install --cask hammerspoon. The current release is 1.1.1 (February 2026). It needs macOS 13 Ventura or later and runs natively on Apple silicon. - Open it and allow it under System Settings → Privacy & Security → Accessibility. Without that permission it can read your config but can't move a single window.
- Click the hammer in the menu bar and choose Open Config. That opens
~/.hammerspoon/init.lua, which is where everything below goes.
After every edit, choose Reload Config from the same menu. If something's wrong, the Console in that menu shows the Lua error and the line it came from.
A Hammerspoon window management config you can paste
This gives you halves, full screen, thirds and two-thirds on a "hyper" chord of ⌃⌥⌘, which macOS doesn't use for anything by default.
hs.window.animationDuration = 0 -- snap instantly instead of sliding
local hyper = { "ctrl", "alt", "cmd" }
-- Returns a function that moves the focused window to a fraction of its screen.
local function place(x, y, w, h)
return function()
local win = hs.window.focusedWindow()
if win then win:moveToUnit({ x, y, w, h }) end
end
end
-- Halves and full screen
hs.hotkey.bind(hyper, "Left", place(0, 0, 0.5, 1))
hs.hotkey.bind(hyper, "Right", place(0.5, 0, 0.5, 1))
hs.hotkey.bind(hyper, "Up", place(0, 0, 1, 1))
-- Thirds and two-thirds
hs.hotkey.bind(hyper, "D", place(0, 0, 1/3, 1))
hs.hotkey.bind(hyper, "F", place(1/3, 0, 1/3, 1))
hs.hotkey.bind(hyper, "G", place(2/3, 0, 1/3, 1))
hs.hotkey.bind(hyper, "E", place(0, 0, 2/3, 1))
hs.hotkey.bind(hyper, "T", place(1/3, 0, 2/3, 1))
-- Send the window to the next display
hs.hotkey.bind(hyper, "N", function()
local win = hs.window.focusedWindow()
if win then win:moveToScreen(win:screen():next()) end
end)
How it works
moveToUnittakes four fractions of the screen: x, y, width, height.{0, 0, 0.5, 1}means start at the left edge, at the top, half as wide, full height. Every layout you'll ever want is one of these four-number rectangles, so adding quarters is just{0, 0, 0.5, 0.5}and so on.hs.window.animationDuration = 0turns off the default slide. Most people who try both prefer the instant snap.moveToScreen(win:screen():next())moves the window to the next display and keeps its relative size and position. Hammerspoon also hasmoveOneScreenEast/West/North/Southif you'd rather aim by direction.
The if win then guard matters. When the desktop or a window-less app is focused, focusedWindow() returns nil, and without the check the hotkey throws an error instead of doing nothing.
Add a keyboard-driven grid with hs.grid
The other half of Hammerspoon's window tools is hs.grid, which divides each screen into cells. Add this to the same file:
hs.grid.setGrid("3x2")
hs.grid.setMargins({ 8, 8 }) -- gaps between windows, in points
hs.hotkey.bind(hyper, "Space", function() hs.grid.show() end)
hs.grid.show() lays a grid over the focused window's screen with a letter on each cell. Type the letter for one corner of the area you want, then the opposite corner, and the window fills that rectangle. You can also select a cell and steer with the arrow keys, then press return. The default grid is 3 × 3, so setGrid("3x2") gives you the shape that covers thirds, two-thirds, top and bottom halves and full screen on a normal display. You can set a different grid per screen if one of yours is an ultrawide.
Functions like hs.grid.pushWindowLeft and hs.grid.resizeWindowWider let you bind nudge-and-grow keys to the same grid without opening the overlay.
Spoons: window management you don't have to write
A Spoon is a packaged Hammerspoon plug-in. Download its zip from the official Spoons list, unzip it, double-click the .spoon and Hammerspoon installs it into ~/.hammerspoon/Spoons. Then load it with hs.loadSpoon("Name") and call its bindHotkeys method. The window-related ones worth knowing:
| Spoon | What it gives you | Good for |
|---|---|---|
| MiroWindowsManager | Hyper + arrows for halves and corners; press again to cycle ½ → ⅓ → ⅔ | ShiftIt and Spectacle refugees who want arrow keys |
| WindowHalfsAndThirds | Simple hotkeys for half- and third-of-screen sizes | The config above, already written |
| WindowGrid | Sets up hs.grid and binds a key to show it |
The grid without the boilerplate |
| WindowScreenLeftAndRight | Moves windows between displays | Multi-monitor desks |
| PaperWM-style scroller | Windows on an endless horizontal strip | People who like scrolling tilers such as niri |
There's also a community ShiftIt Spoon that copies ShiftIt's chords. Our ShiftIt alternative guide covers that migration.
Gotchas that catch everyone
- Some apps refuse exact sizes. Terminal and some editors snap to whole character cells, and many apps have a minimum width. A "third" can come out a few points off or overlap its neighbour. That's the app, not your Lua.
- Shortcut clashes fail silently. If another app already owns ⌃⌥⌘←, one of them loses. See Mac shortcut conflicts for how to find the culprit.
- Store anything long-lived in a variable. The docs warn that watchers and timers created in
init.luaare cleaned up later unless you keep a reference to them. Hotkeys made withhs.hotkey.bindare fine, but a window filter or timer assigned to nothing will stop working after a while. - It's yours to maintain. When you move to a new Mac, your tiler is a file you have to copy over. Keep
~/.hammerspoonin your dotfiles.
If nothing moves at all, it's almost always the Accessibility permission. Our window manager not working guide walks through resetting it.
Hammerspoon vs a ready-made window manager
| Hammerspoon (your config) | Hammerspoon + Spoon | Rectangle | Let's Tile | |
|---|---|---|---|---|
| Price | Free | Free | Free (Pro is paid) | Free tier, $9.99 Pro one-time |
| Setup | Write and maintain Lua | Install a Spoon, a few lines | Install and go | Install and go |
| How you pick a layout | Whatever you script | One hotkey per region | One shortcut per region | One shortcut, then arrows on a visible grid |
| Visible grid | Yes, hs.grid.show() with letter hints |
WindowGrid | No | Yes, the core of the app |
| Open source | Yes | Yes | Yes | No |
| Minimum macOS | 13 Ventura | 13 Ventura | 14 Sonoma | 14 Sonoma |
Choose Hammerspoon if you already use it, or if window placement is one part of something bigger: launching apps into set positions, reacting when a display connects, layouts tied to Wi-Fi networks. Nothing else gives you that much control for free.
Choose an app if all you wanted was the windows. If you'd rather have a shortcut per region, use Rectangle. If you liked the idea of hs.grid.show() but not the setup, Let's Tile is that idea as a finished app. Press ⌘↵ and a grid drops over the window you were using. Move with the arrow keys, hold ⇧ and press an arrow to stretch across cells, then press ↵. You steer with arrows instead of typing letters, so there's nothing to learn. The free tier is a 3 × 2 grid, permanently, which gives you thirds, two-thirds, top and bottom halves and full screen (Pro adds side-by-side halves and quarters). Pro is $9.99 once and adds any grid you like, a different grid per display remembered automatically, throwing the window to your other display mid-tile and margins between cells. There's no account, one key covers up to 20 devices and the app sends no telemetry.
Here's the honest trade-off. Let's Tile is newer than Hammerspoon and Rectangle, it isn't open source and it can't be scripted. If you need code, you'll stay with Hammerspoon.
Frequently asked questions
Is Hammerspoon a tiling window manager? Not on its own. It's an automation toolkit with window APIs. It moves windows when you ask, and you write or install the rules. Automatic tilers like AeroSpace and yabai arrange every window for you. Our yabai vs AeroSpace comparison covers those.
Does Hammerspoon work on Apple silicon and the latest macOS? Yes. It's been universal since 2021, and 1.1.1 requires macOS 13 Ventura or later.
Can Hammerspoon switch windows too?
Yes. It has a built-in hs.window.switcher and an AppWindowSwitcher Spoon. If you'd rather not script that either, Let's Switch does keyboard window switching with live previews out of the box.
Hammerspoon rewards people who enjoy shaping their tools, and thirty lines of Lua is a small price for a tiler that does exactly what you want. If you'd rather have the grid without writing the config, try Let's Tile's free grid and see if one shortcut is enough.