Skip to content

Instantly share code, notes, and snippets.

@finnigja
Created November 7, 2018 00:35
Show Gist options
  • Save finnigja/bbe85b39a16d5f4ffd250e00069411a6 to your computer and use it in GitHub Desktop.
Save finnigja/bbe85b39a16d5f4ffd250e00069411a6 to your computer and use it in GitHub Desktop.
Simple window tiling with Hammerspoon
-- http://www.hammerspoon.org/go/
-- basic key shortcuts for window tiling
hs.window.animationDuration = 0
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "M", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x - 4
f.y = max.y
f.w = max.w + 2
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Left", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x - 4
f.y = max.y
f.w = max.w / 2 + 2
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Right", 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) - 2
f.y = max.y
f.w = max.w / 2 + 2
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Up", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = 0
f.y = 0
f.w = max.w
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Down", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = 0
f.y = max.y + (max.h / 2) - 2
f.w = max.w
f.h = (max.h / 2) + 4
win:setFrame(f)
end)
--type-paste (for sites/apps that block actual-paste into password field)
hs.hotkey.bind({"cmd", "alt"}, "V", function()
hs.eventtap.keyStrokes(hs.pasteboard.getContents())
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment