Skip to content

Instantly share code, notes, and snippets.

@eduardoarandah
Created February 22, 2026 19:09
Show Gist options
  • Select an option

  • Save eduardoarandah/84d54124b7658b7865e36902e102b811 to your computer and use it in GitHub Desktop.

Select an option

Save eduardoarandah/84d54124b7658b7865e36902e102b811 to your computer and use it in GitHub Desktop.
automate window movement with hammerspoon
-- automatically reload configuration on change
hs.loadSpoon("ReloadConfiguration")
spoon.ReloadConfiguration:start()
-- cmd + alt + v types the clipboard contents as keystrokes
hs.hotkey.bind({ "cmd", "alt" }, "V", function()
hs.eventtap.keyStrokes(hs.pasteboard.getContents())
end)
-- move windows like Rectangle app using https://www.hammerspoon.org/Spoons/WindowHalfsAndThirds.html
hs.loadSpoon("WindowHalfsAndThirds")
spoon.WindowHalfsAndThirds:bindHotkeys({
top_half = { { "ctrl", "cmd" }, "Up" },
bottom_half = { { "ctrl", "cmd" }, "Down" },
left_half = { { "ctrl", "cmd" }, "Left" },
right_half = { { "ctrl", "cmd" }, "Right" },
--
top_left = { { "ctrl", "cmd" }, "1" },
top_right = { { "ctrl", "cmd" }, "2" },
bottom_left = { { "ctrl", "cmd" }, "3" },
bottom_right = { { "ctrl", "cmd" }, "4" },
--
max = { { "ctrl", "alt", "cmd" }, "Up" },
-- third_left = { { "ctrl", "alt" }, "Left" },
-- third_right = { { "ctrl", "alt" }, "Right" },
-- third_up = { { "ctrl", "alt" }, "Up" },
-- third_down = { { "ctrl", "alt" }, "Down" },
-- max_toggle = { { "ctrl", "alt", "cmd" }, "f" },
-- undo = { { "alt", "cmd" }, "z" },
-- center = { { "alt", "cmd" }, "c" },
-- larger = { { "alt", "cmd", "shift" }, "Right" },
-- smaller = { { "alt", "cmd", "shift" }, "Left" },
})
-- move windows between screens
hs.loadSpoon("WindowScreenLeftAndRight")
spoon.WindowScreenLeftAndRight:bindHotkeys({
screen_left = { { "ctrl", "alt", "cmd" }, "Left" },
screen_right = { { "ctrl", "alt", "cmd" }, "Right" },
})
-- helper function to open or focus an app
local function openApp(appName)
hs.application.launchOrFocus(appName)
end
-- Shift + F1 → Finder
hs.hotkey.bind({ "shift" }, "F1", function()
openApp("Finder")
end)
-- Shift + F2 → Google Chrome
hs.hotkey.bind({ "shift" }, "F2", function()
openApp("Google Chrome")
end)
-- Shift + F3 → Ghostty
hs.hotkey.bind({ "shift" }, "F3", function()
openApp("Ghostty")
end)
-- Shift + F4 → WhatsApp
hs.hotkey.bind({ "shift" }, "F4", function()
openApp("WhatsApp")
end)
-- Shift + F5 → Spotify
hs.hotkey.bind({ "shift" }, "F5", function()
openApp("Spotify")
end)
-- Shift + F6 → Reminders
hs.hotkey.bind({ "shift" }, "F6", function()
openApp("Reminders")
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment