- 公式サイトからHammerspoonをダウンロードし、~/Applications ディレクトリへドラッグアンドドロップ
- Hammerspoonを起動し、メニューバーアイコン -> Preferences...
- 「Launch Hammerspoon at login」をチェックする
- 「Enable Accesibility」を押して、Macの設定からHammerspoonにアクセス権を与える
- キーバインドを設定
~/.hammerspoon/init.lua
hs.window.animationDuration = 0
units = {
right50 = { x = 0.50, y = 0.00, w = 0.50, h = 1.00 },
left50 = { x = 0.00, y = 0.00, w = 0.50, h = 1.00 },
top50 = { x = 0.00, y = 0.00, w = 1.00, h = 0.50 },
bot50 = { x = 0.00, y = 0.50, w = 1.00, h = 0.50 },
righttop = { x = 0.50, y = 0.00, w = 0.50, h = 0.50 },
lefttop = { x = 0.00, y = 0.00, w = 0.50, h = 0.50 },
rightbot = { x = 0.50, y = 0.50, w = 0.50, h = 0.50 },
leftbot = { x = 0.00, y = 0.50, w = 0.50, h = 0.50 },
maximum = { x = 0.00, y = 0.00, w = 1.00, h = 1.00 }
}
mash = { 'ctrl', 'cmd' }
hs.hotkey.bind(mash, 'right', function() hs.window.focusedWindow():move(units.right50, nil, true) end)
hs.hotkey.bind(mash, 'left', function() hs.window.focusedWindow():move(units.left50, nil, true) end)
hs.hotkey.bind(mash, 'up', function() hs.window.focusedWindow():move(units.top50, nil, true) end)
hs.hotkey.bind(mash, 'down', function() hs.window.focusedWindow():move(units.bot50, nil, true) end)
hs.hotkey.bind(mash, 'i', function() hs.window.focusedWindow():move(units.righttop, nil, true) end)
hs.hotkey.bind(mash, 'u', function() hs.window.focusedWindow():move(units.lefttop, nil, true) end)
hs.hotkey.bind(mash, 'k', function() hs.window.focusedWindow():move(units.rightbot, nil, true) end)
hs.hotkey.bind(mash, 'j', function() hs.window.focusedWindow():move(units.leftbot, nil, true) end)
hs.hotkey.bind(mash, 'm', function() hs.window.focusedWindow():move(units.maximum, nil, true) end)