A simple Hammerspoon script to record and replay window positions with hotkeys.
Existing window managers (Rectangle, Magnet, Moom) only offer preset positions. This lets you record any window position and replay it instantly.
- Install Hammerspoon (or
brew install --cask hammerspoon) - Copy
init.luato~/.hammerspoon/init.lua - Reload Hammerspoon config
| Hotkey | Action |
|---|---|
Cmd+Option+1 |
Snap window to preset position (edit in script) |
Cmd+Option+R |
Record current window position to next slot (2-9) |
Cmd+Option+2-9 |
Snap window to recorded position |
Cmd+Option+0 |
Show all saved positions |
Cmd+Option+. |
Clear all saved positions |
- Arrange a window exactly where you want it
- Press
Cmd+Option+R→ "Saved to Cmd+Option+2" - Now
Cmd+Option+2snaps any focused window to that position - Repeat for more positions (slots 3-9)
Positions are saved to ~/.hammerspoon/window-positions.json and persist across restarts.
Edit the preset in slot 1:
win:setFrame(hs.geometry.rect(100, 100, 800, 600))
-- x y width heightMIT
