Skip to content

Instantly share code, notes, and snippets.

@fukayatsu
Last active September 6, 2020 20:48
Show Gist options
  • Save fukayatsu/3fe0fff3ea86c2443620c0efead90060 to your computer and use it in GitHub Desktop.
Save fukayatsu/3fe0fff3ea86c2443620c0efead90060 to your computer and use it in GitHub Desktop.
Hammerspoon config
-- Config for https://github.com/Hammerspoon/hammerspoon
local function keyStroke(mod, key)
return function() hs.eventtap.keyStroke(mod, key) end
end
local function remap(appName, mod1, key1, mod2, key2)
if (not appName) then
return hs.hotkey.bind(mod1, key1, keyStroke(mod2, key2))
end
local hotkey = hs.hotkey.new(mod1, key1, keyStroke(mod2, key2))
return hs.window.filter.new(appName)
:subscribe(hs.window.filter.windowFocused, function() hotkey:enable() end)
:subscribe(hs.window.filter.windowUnfocused, function() hotkey:disable() end)
end
-- global remap
remap(nil, {'ctrl'}, '[', {}, 'escape')
-- remap for Slack.app
-- see also: http://blog.glidenote.com/blog/2014/08/06/custom-keybind-for-slack/
remap('Slack', {'ctrl'}, 'p', {'alt'}, 'up')
remap('Slack', {'ctrl'}, 'n', {'alt'}, 'down')
remap('Slack', {'alt'}, 'a', {'alt', 'shift'}, 'down')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment