Skip to content

Instantly share code, notes, and snippets.

@nyergler
Created May 21, 2018 15:57
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nyergler/7056c61174194a9af9b4d5d727f1b566 to your computer and use it in GitHub Desktop.
Save nyergler/7056c61174194a9af9b4d5d727f1b566 to your computer and use it in GitHub Desktop.
My Hammerspoon window management configuration
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "W", function()
hs.alert.show(
"Hello World!",
{
textFont= "Comic Sans MS",
textSize=72,
fadeOutDuration=1
}
)
end)
-- Magnet replacement bindings
hs.hotkey.bind({"ctrl", "alt"}, "left", function()
-- size focused window to left half of display
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({"ctrl", "alt"}, "a", function()
-- size focused window to left third of display
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({"ctrl", "alt"}, "s", function()
-- size focused window to middle third of display
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({"ctrl", "alt"}, "d", function()
-- size focused window to right third of display
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({"ctrl", "alt"}, "right", function()
-- size focused window to right half of display
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({"ctrl", "alt"}, "return", function()
-- size focused window to size of desktop
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
win:setFrame(f)
end)
hs.hotkey.bind({"ctrl", "alt"}, "up", function()
-- size focused window to top half of display
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({"ctrl", "alt"}, "down", function()
-- size focused window to bottom half of display
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 / 2)
f.w = max.w
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "F", function()
-- toggle the focused window to full screen (workspace)
local win = hs.window.focusedWindow()
win:setFullScreen(not win:isFullScreen())
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "right", function()
-- move the focused window one display to the right
local win = hs.window.focusedWindow()
win:moveOneScreenEast()
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "left", function()
-- move the focused window one display to the left
local win = hs.window.focusedWindow()
win:moveOneScreenWest()
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function()
RoundedCorners = hs.loadSpoon('RoundedCorners')
RoundedCorners.radius = 20
RoundedCorners:start()
hs.alert.show("Oooooooooh, so ROUND!")
end)
-- hs.loadSpoon('CircleClock')
-- hs.loadSpoon('Calendar')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment