Skip to content

Instantly share code, notes, and snippets.

@holin
Created February 1, 2017 14:46
Show Gist options
  • Select an option

  • Save holin/7fb7622a7599ec3d90620f27106e632e to your computer and use it in GitHub Desktop.

Select an option

Save holin/7fb7622a7599ec3d90620f27106e632e to your computer and use it in GitHub Desktop.
my Hammerspoon init file
local function keyCode(key, modifiers)
modifiers = modifiers or {}
return function()
hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), true):post()
hs.timer.usleep(1000)
hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), false):post()
end
end
hs.hotkey.bind({'ctrl'}, 'j', keyCode('left'), nil, keyCode('left'))
hs.hotkey.bind({'ctrl'}, 'k', keyCode('down'), nil, keyCode('down'))
hs.hotkey.bind({'ctrl'}, 'i', keyCode('up'), nil, keyCode('up'))
hs.hotkey.bind({'ctrl'}, 'l', keyCode('right'), nil, keyCode('right'))
-- home, end
hs.hotkey.bind({'cmd', 'ctrl'}, 'k', function()
hs.eventtap.event.newKeyEvent({}, 'home', true):post()
end)
hs.hotkey.bind({'cmd', 'ctrl'}, ',', function()
hs.eventtap.event.newKeyEvent({}, 'end', true):post()
end)
-- focus
hs.hotkey.bind({'cmd', 'shift'}, 'e', function()
hs.application.launchOrFocus("Terminal")
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment