Skip to content

Instantly share code, notes, and snippets.

@stringsn88keys
Created April 1, 2017 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stringsn88keys/131e8461e002ef5664422042d1d303ad to your computer and use it in GitHub Desktop.
Save stringsn88keys/131e8461e002ef5664422042d1d303ad to your computer and use it in GitHub Desktop.
Hammerspoon init script that allows 1-9 to move windows into 9ths of the screen
function move_to_third(r,c)
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local extents = screen:frame()
f.x = extents.x + (extents.w / 3) * c
f.y = extents.y + (extents.h / 3) * r
f.w = extents.w / 3
f.h = extents.h / 3
win:setFrame(f)
end
for i=1,9 do
hs.hotkey.bind({"cmd", "alt", "ctrl"}, tostring(i), function()
move_to_third(math.floor((i-1)/3),(i-1)%3)
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment