Skip to content

Instantly share code, notes, and snippets.

@raphaeltraviss
Created October 24, 2023 15:30
Show Gist options
  • Save raphaeltraviss/8923e568e3db1a3dc6afe370c8f22aa1 to your computer and use it in GitHub Desktop.
Save raphaeltraviss/8923e568e3db1a3dc6afe370c8f22aa1 to your computer and use it in GitHub Desktop.
Hammerspoon Four Sides Tiling
hs.hotkey.bind({"ctrl", "shift", "cmd"}, "Left", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w / 2
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"ctrl", "shift", "cmd"}, "Right", function()
local win = hs.window.focusedWindow()
local winFrame = win:frame()
local screen = win:screen()
local screenFrame = screen:frame()
winFrame.x = screenFrame.x + (screenFrame.w / 2)
winFrame.y = screenFrame.y
winFrame.w = screenFrame.w / 2
winFrame.h = screenFrame.h
win:setFrame(winFrame)
end)
hs.hotkey.bind({"ctrl", "shift", "cmd"}, "Up", function()
local win = hs.window.focusedWindow()
local winFrame = win:frame()
local screen = win:screen()
local screenFrame = screen:frame()
winFrame.y = 0
winFrame.h = screenFrame.h / 2
win:setFrame(winFrame)
end)
hs.hotkey.bind({"ctrl", "shift", "cmd"}, "Down", function()
local win = hs.window.focusedWindow()
local winFrame = win:frame()
local screen = win:screen()
local screenFrame = screen:frame()
winFrame.y = 0
winFrame.h = screenFrame.h
win:setFrame(winFrame)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment