Skip to content

Instantly share code, notes, and snippets.

@JacobJaffe
Created February 25, 2026 01:08
Show Gist options
  • Select an option

  • Save JacobJaffe/ef8008fe446f95f6f82c3f5948dc9419 to your computer and use it in GitHub Desktop.

Select an option

Save JacobJaffe/ef8008fe446f95f6f82c3f5948dc9419 to your computer and use it in GitHub Desktop.
hammerspoon config
hs.fnutils.each({
-- Sides:
{ key = 'Left', padKey = 'pad4', x = 0, y = 0, h = 1, w = 0.5 },
{ key = 'Right', padKey = 'pad6', x = 0.5, y = 0, h = 1, w = 0.5 },
{ key = 'Up', padKey = 'pad8', x = 0, y = 0, h = 0.5, w = 1 },
{ key = 'Down', padKey = 'pad2', x = 0, y = 0.5, h = 0.5, w = 1 },
-- Corners:
{ key = nil, padKey = 'pad7', x = 0, y = 0, h = 0.5, w = 0.5, },
{ key = nil, padKey = 'pad9', x = 0.5, y = 0, h = 0.5, w = 0.5, },
{ key = nil, padKey = 'pad1', x = 0, y = 0.5, h = 0.5, w = 0.5, },
{ key = nil, padKey = 'pad3', x = 0.5, y = 0.5, h = 0.5, w = 0.5, },
-- Full screen:
{ key = 'pad5', padKey = 'pad5', x = 0, y = 0, h = 1, w = 1 },
},
function(map)
move = function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + (max.w * map.x)
f.y = max.y + (max.h * map.y)
f.w = max.w * map.w
f.h = max.h * map.h
win:setFrame(f)
end
-- For both key and padKey, we'll bind the same function.
-- If nill, we skip the key binding.
if map.key then
hs.hotkey.bind({ "cmd", "alt", "ctrl" }, map.key, move)
end
if map.padKey then
hs.hotkey.bind({ "cmd", "alt", "ctrl" }, map.padKey, move)
end
end
)
function reloadConfig(files)
doReload = false
for _, file in pairs(files) do
if file:sub(-4) == ".lua" then
doReload = true
end
end
if doReload then
hs.reload()
end
end
myWatcher = hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reloadConfig):start()
hs.alert.show("Config loaded")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment