Skip to content

Instantly share code, notes, and snippets.

@geberl
Last active October 21, 2020 12:38
Show Gist options
  • Save geberl/0f9bb4d89d15cc56b23d82bc5a7c35ab to your computer and use it in GitHub Desktop.
Save geberl/0f9bb4d89d15cc56b23d82bc5a7c35ab to your computer and use it in GitHub Desktop.
My Hammerspoon (https://github.com/Hammerspoon/hammerspoon) config file. Set up to help with window management on a DELL U3419W widescreen (3440x1440) monitor.
-------------------------------------------------------------------------------
-- ShiftIt / Spectacle style window manager
-------------------------------------------------------------------------------
-- Source/inspiration: https://github.com/fikovnik/ShiftIt/wiki/The-Hammerspoon-Alternative
-- Docs hotkey module: https://www.hammerspoon.org/docs/hs.hotkey.html
-- Docs keycodes: https://www.hammerspoon.org/docs/hs.keycodes.html#map
hs.window.animationDuration = 0.1
units = {
left33 = { x = 0.00, y = 0.00, w = 0.33, h = 1.00 },
center33 = { x = 0.33, y = 0.00, w = 0.34, h = 1.00 },
right33 = { x = 0.67, y = 0.00, w = 0.33, h = 1.00 },
left66 = { x = 0.00, y = 0.00, w = 0.67, h = 1.00 },
right66 = { x = 0.33, y = 0.00, w = 0.67, h = 1.00 },
center = { x = 0.25, y = 0.10, w = 0.50, h = 0.80 },
maximum = { x = 0.00, y = 0.00, w = 1.00, h = 1.00 },
left50 = { x = 0.00, y = 0.00, w = 0.50, h = 1.00 },
right50 = { x = 0.50, y = 0.00, w = 0.50, h = 1.00 }
}
mash = { 'ctrl', 'alt', 'cmd' }
hs.hotkey.bind(mash, 'q', function() hs.window.focusedWindow():move(units.left33, nil, true) end)
hs.hotkey.bind(mash, 'w', function() hs.window.focusedWindow():move(units.center33, nil, true) end)
hs.hotkey.bind(mash, 'e', function() hs.window.focusedWindow():move(units.right33, nil, true) end)
hs.hotkey.bind(mash, 'a', function() hs.window.focusedWindow():move(units.left66, nil, true) end)
hs.hotkey.bind(mash, 'd', function() hs.window.focusedWindow():move(units.right66, nil, true) end)
hs.hotkey.bind(mash, 'm', function() hs.window.focusedWindow():move(units.maximum, nil, true) end)
hs.hotkey.bind(mash, 'c', function() hs.window.focusedWindow():move(units.center, nil, true) end)
hs.hotkey.bind(mash, '1', function() hs.window.focusedWindow():move(units.left50, nil, true) end)
hs.hotkey.bind(mash, '2', function() hs.window.focusedWindow():move(units.right50, nil, true) end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment