Skip to content

Instantly share code, notes, and snippets.

@austintgriffith
Last active October 21, 2018 19:32
Show Gist options
  • Save austintgriffith/1f51ca98e7c8dfcf285d7befe8c74ec2 to your computer and use it in GitHub Desktop.
Save austintgriffith/1f51ca98e7c8dfcf285d7befe8c74ec2 to your computer and use it in GitHub Desktop.
hs.hotkey.bind({"shift", "ctrl","cmd"}, "Q", 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 + max.h / 6
f.w = max.w / 2
f.h = max.h * 5/6
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl","cmd"}, "W", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 4
f.y = max.y + max.h / 6
f.w = max.w / 2
f.h = max.h * 5/6
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl","cmd"}, "1", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 4 - 60
f.y = max.y + max.h / 6 - 60
f.w = max.w / 2
f.h = max.h * 5/6
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl","cmd"}, "2", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 4 - 60 *2
f.y = max.y + max.h / 6 - 60 *2
f.w = max.w / 2
f.h = max.h * 5/6
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl","cmd"}, "3", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 4 - 60*3
f.y = max.y + max.h / 6 - 60*3
f.w = max.w / 2
f.h = max.h * 5/6
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl","cmd"}, "4", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 4 - 60*4
f.y = max.y + max.h / 6 - 60*4
f.w = max.w / 2
f.h = max.h * 5/6
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl","cmd"}, "E", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 2
f.y = max.y + max.h / 6
f.w = max.w / 2
f.h = max.h * 5/6
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, "Q", 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 / 3
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, "W", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 3
f.y = max.y
f.w = max.w / 3
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, "E", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 3 * 2
f.y = max.y
f.w = max.w / 3
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, "U", 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 / 3
f.h = max.h / 4
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, "J", 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 + max.h / 4
f.w = max.w / 3
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, "M", 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 + max.h / 4 * 3
f.w = max.w / 3
f.h = max.h / 4
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, "I", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 3
f.y = max.y
f.w = max.w / 3
f.h = max.h / 4
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, "K", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 3
f.y = max.y + max.h / 4
f.w = max.w / 3
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, ",", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 3
f.y = max.y + max.h / 4 * 3
f.w = max.w / 3
f.h = max.h / 4
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, "O", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 3 * 2
f.y = max.y
f.w = max.w / 3
f.h = max.h / 4
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, "L", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 3 * 2
f.y = max.y + max.h / 4
f.w = max.w / 3
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"shift", "ctrl"}, ".", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 3 * 2
f.y = max.y + max.h / 4 * 3
f.w = max.w / 3
f.h = max.h / 4
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "shift", "ctrl"}, "J", 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({"cmd", "shift", "ctrl"}, "L", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + (max.w / 2)
f.y = max.y
f.w = max.w / 2
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "shift", "ctrl"}, "I", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.y = max.y
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "shift", "ctrl"}, "K", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.y = f.y + (max.h / 2)
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "shift", "ctrl"}, "a", 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 + 100
f.w = max.w / 2
f.h = max.h - 100
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "shift", "ctrl"}, "s", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + 50
f.y = max.y + 50
f.w = max.w / 2
f.h = max.h - 50
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "shift", "ctrl"}, "d", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + 100
f.y = max.y
f.w = max.w - 300
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "shift", "ctrl"}, "f", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = (max.w/2)
f.y = max.y + 100
f.w = max.w / 2
f.h = max.h - 100
win:setFrame(f)
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
hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reloadConfig):start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment