Skip to content

Instantly share code, notes, and snippets.

@sergeylukin
Last active November 5, 2019 08:17
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 sergeylukin/202be0a38d7690feb973841520ebee78 to your computer and use it in GitHub Desktop.
Save sergeylukin/202be0a38d7690feb973841520ebee78 to your computer and use it in GitHub Desktop.
Hammerspoon Hyper key configuration
--Reload config
local hyper = { "cmd", "alt", "ctrl", "shift" }
hs.hotkey.bind(hyper, "0", function()
hs.reload()
hs.notify.new({title="Hammerspoon", informativeText="Config loaded"}):send()
end)
--Resize windiows
hs.window.animationDuration = 0
hs.hotkey.bind(hyper, "h", function()
local win = hs.window.focusedWindow();
if not win then return end
win:moveToUnit(hs.layout.left50)
end)
hs.hotkey.bind(hyper, "j", function()
local win = hs.window.focusedWindow();
if not win then return end
win:moveToUnit(hs.layout.maximized)
end)
hs.hotkey.bind(hyper, "k", function()
local win = hs.window.focusedWindow();
if not win then return end
win:moveToScreen(win:screen():next())
end)
hs.hotkey.bind(hyper, "l", function()
local win = hs.window.focusedWindow();
if not win then return end
win:moveToUnit(hs.layout.right50)
end)
--Hyper + a/s/d/f for quick App switch
local applicationHotkeys = {
a = 'Brave Browser',
s = 'Google Chrome',
d = 'iTerm',
f = 'Finder',
e = 'Sublime Text'
}
for key, app in pairs(applicationHotkeys) do
hs.hotkey.bind(hyper, key, function()
hs.application.launchOrFocus(app)
end)
end
--Lock screen
hs.hotkey.bind(hyper, "q", function()
hs.caffeinate.lockScreen()
end)
--Fullscreen
hs.hotkey.bind(hyper, "return", function()
local win = hs.window.frontmostWindow()
win:setFullscreen(not win:isFullscreen())
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment