Last active
October 26, 2016 13:57
-
-
Save scottming/d16e213a78e5ea2649d039381bd54d06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local cmdalt = {"cmd", "alt"} | |
local capslock = {'cmd', "alt", "shift", "ctrl"} | |
-- Set grid size. | |
hs.grid.GRIDWIDTH = 4 | |
hs.grid.GRIDHEIGHT = 6 | |
hs.grid.MARGINX = 0 | |
hs.grid.MARGINY = 0 | |
hs.window.animationDuration = 0 | |
hs.hotkey.bind(cmdalt, 'R', hs.reload) | |
hs.hotkey.bind(cmdalt, 'M', hs.grid.maximizeWindow) | |
hs.hotkey.bind(cmdalt, 'F', | |
function() | |
hs.window.focusedWindow():toggleFullScreen() | |
end) | |
hs.hotkey.bind(cmdalt, 'J', hs.grid.pushWindowDown) | |
hs.hotkey.bind(cmdalt, 'K', hs.grid.pushWindowUp) | |
hs.hotkey.bind(cmdalt, 'H', hs.grid.pushWindowLeft) | |
hs.hotkey.bind(cmdalt, 'L', hs.grid.pushWindowRight) | |
hs.hotkey.bind(capslock, "`", function() | |
local win = hs.window.focusedWindow() | |
local f = win:frame() | |
local screen = win:screen() | |
local max = screen:frame() | |
f.x = max.x / 2 | |
f.y = max.y / 2 | |
f.w = max.w | |
f.h = max.h | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind(capslock, "6", function() | |
local win = hs.window.focusedWindow() | |
local f = win:frame() | |
local screen = win:screen() | |
local max = screen:frame() | |
f.x = max.w / 4 | |
f.y = max.y | |
f.w = max.w / 2 | |
f.h = max.h / 3 * 2 | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind(capslock, "5", 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(cmdalt, "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(capslock, "7", 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 | |
f.w = max.w / 2 | |
f.h = max.h | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind(cmdalt, "Right", 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 | |
f.w = max.w / 2 | |
f.h = max.h | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind(cmdalt, "Up", 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 | |
f.h = max.h / 2 | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind(cmdalt, "Down", 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.h / 2 | |
f.w = max.w | |
f.h = max.h / 2 | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind(capslock, "R", | |
function() | |
hs.hints.windowHints() | |
end) | |
local app_map = { | |
["1"] = "iTerm", | |
["2"] = "Termianl", | |
["M"] = "TextMate", | |
["C"] = "Google Chrome", | |
["O"] = "Firefox", | |
["W"] = "Wechat" | |
} | |
local function bind_app() | |
for key, app in pairs(app_map) do | |
hs.hotkey.bind({"alt"}, key, | |
function() | |
hs.application.open(app) | |
end | |
) | |
end | |
end | |
bind_app() | |
hs.alert.show("Hammerspoon, at your service.", 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment