Skip to content

Instantly share code, notes, and snippets.

@yohm
Created February 2, 2017 00:06
Show Gist options
  • Save yohm/a2c8f4f76a9ad64fcbafda4072619e4c to your computer and use it in GitHub Desktop.
Save yohm/a2c8f4f76a9ad64fcbafda4072619e4c to your computer and use it in GitHub Desktop.
My configuration of hammerspoon
local function disableAllHotkeys()
for k, v in pairs(hs.hotkey.getHotkeys()) do
v['_hk']:disable()
end
end
local function enableAllHotkeys()
for k, v in pairs(hs.hotkey.getHotkeys()) do
v['_hk']:enable()
end
end
local function keyCode(key, modifiers)
modifiers = modifiers or {}
return function()
disableAllHotkeys()
hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), true):post()
hs.timer.usleep(1000)
hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), false):post()
enableAllHotkeys()
end
end
local function remapKey(modifiers, key, keyCode)
hs.hotkey.bind(modifiers, key, keyCode, nil, keyCode)
end
remapKey({'ctrl'}, ';', keyCode(';', {}))
remapKey({}, ';', keyCode('return'))
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function()
hs.reload()
end)
hs.alert.show("Config loaded")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment