Skip to content

Instantly share code, notes, and snippets.

@anzdaddy
Last active May 23, 2025 01:23
Show Gist options
  • Save anzdaddy/b56171e2504e6b3d29a42292c81aa656 to your computer and use it in GitHub Desktop.
Save anzdaddy/b56171e2504e6b3d29a42292c81aa656 to your computer and use it in GitHub Desktop.
-- https://gist.github.com/marcelocantos/91d14aa9f51c76cd7903439afb74f22a
logger = require("hs.logger").new("init", "debug")
-- bind binds keys more conveniently. Input should be some variant of "⌥⌘⇧-k".
function bind(bindings)
for input, char in pairs(bindings) do
local modifiers = {}
for code, key in pairs({["⌥"]="alt", ["⌘"]="cmd", ["⇧"]="shift"}) do
if input:find(code) then
table.insert(modifiers, key)
end
end
hotkey = string.match(input, "-(.*)")
hs.hotkey.bind(modifiers, hotkey, function() hs.eventtap.keyStrokes(char) end)
end
end
-- some handy rebindings
bind({
["⌥ -["] = "‘",
["⌥ -\\"] = "«",
["⌥ -]"] = "’",
["⌥ ⇧-["] = "“",
["⌥ ⇧-]"] = "”",
["⌥ ⇧-;"] = "⋮",
[" ⌘⇧-8"] = "×",
["⌥⌘⇧-right"] = "→",
["⌥⌘⇧-up"] = "↑",
["⌥⌘⇧-down"] = "↓",
["⌥⌘⇧-left"] = "←",
["⌥⌘⇧-left"] = "←",
["⌥⌘⇧-,"] = "❮",
["⌥⌘⇧-."] = "❯",
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment