Skip to content

Instantly share code, notes, and snippets.

@Gronis
Last active September 30, 2025 19:37
Show Gist options
  • Select an option

  • Save Gronis/5e0924a14d9915ffeffb59970188e980 to your computer and use it in GitHub Desktop.

Select an option

Save Gronis/5e0924a14d9915ffeffb59970188e980 to your computer and use it in GitHub Desktop.
hammerspoon application toggler
# ~/.config/ghostty/config
theme = shades-of-purple
background = #1f1f1f
foreground = #ffffff
cursor-color = #ffffff
selection-foreground = #000000
selection-background = #eeeeee
bold-is-bright = true
font-feature = -calt
keybind = alt+right=esc:f
keybind = alt+left=esc:b
keybind = super+right=text:\x05
keybind = super+left=text:\x01
keybind = alt+backspace=text:\x1b\x7f
keybind = alt+delete=esc:d
keybind = super+backspace=text:\x15
keybind = super+delete=text:\x0b
keybind = ctrl+alt+left=goto_split:left
keybind = ctrl+alt+right=goto_split:right
keybind = super+alt+left=previous_tab
keybind = super+alt+right=next_tab
macos-titlebar-style = transparent
focus-follows-mouse = true
-- File: ~/.hammerspoon/init.lua
-- This hammerspoon config enables the possibility of using both normal keys and system keys to toggle applications
function create_hotkeys_service()
local service = { event_handlers = {} }
function service.bind_hotkey(modifiers, key, action)
if hs.keycodes.map[key] then
hs.hotkey.bind(modifiers, key, action)
return
end
local down = true
local flags = {}
for i,mod in pairs(modifiers) do
flags[mod] = true
end
if(service.event_handlers[key] == nil) then
service.event_handlers[key] = {}
end
table.insert(service.event_handlers[key], {down, modifiers, action})
end
function service.start()
service.proc = hs.eventtap.new({hs.eventtap.event.types.systemDefined}, function(event)
local system_key = event:systemKey()
local event_modifiers = event:getFlags()
local handlers = service.event_handlers[system_key.key]
if handlers then
for i,handler in pairs(handlers) do
local handler_down = handler[1]
local handler_mods = handler[2]
local handler_action = handler[3]
if system_key.down == handler_down and event_modifiers:containExactly(handler_mods) then
handler_action()
end
end
end
end)
service.proc:start()
end
return service
end
function create_application_service()
local application = {}
function application.toggle_app(app)
local app = hs.application.get(app)
if app then
if not app:mainWindow() then
app:selectMenuItem({app, "New OS window"})
elseif app:isFrontmost() then
app:hide()
else
app:activate()
end
else
hs.application.launchOrFocus(app)
end
end
return application
end
mac = {
hotkeys = create_hotkeys_service(),
application = create_application_service(),
}
mac.hotkeys.bind_hotkey({"cmd"}, "PLAY", function() mac.application.toggle_app('Spotify') end)
mac.hotkeys.bind_hotkey({}, "§", function() mac.application.toggle_app("Ghostty") end)
mac.hotkeys.bind_hotkey({"cmd"}, "§", function() mac.application.toggle_app("Google Chrome") end)
mac.hotkeys.bind_hotkey({"cmd"}, "M", function() mac.application.toggle_app("Mail") end)
mac.hotkeys.bind_hotkey({"cmd"}, ".", function() mac.application.toggle_app("Zed") end)
mac.hotkeys.start()
[
{
"key": "alt+cmd+-",
"command": "editor.action.jumpToBracket",
"when": "editorTextFocus"
},
{
"key": "shift+alt+cmd+-",
"command": "editor.action.selectToBracket"
}
]
font_size 13.0
font_family JetBrainsMonoNL Nerd Font Mono Regular
bold_font JetBrainsMonoNL Nerd Font Mono ExtraBold
italic_font JetBrainsMonoNL Nerd Font Mono Regular Italic
bold_italic_fon JetBrainsMonoNL Nerd Font Mono ExtraBold Italic
window_padding_width 2
draw_minimal_borders yes
hide_window_decorations titlebar-only
map cmd+c copy_or_interrupt
map ctrl+shift+- no_op
map ctrl+shift++ no_op
background #1f1f1f
// Zed settings
//
// For information on how to configure Zed, see the Zed
// documentation: https://zed.dev/docs/configuring-zed
//
// To see all of Zed's default settings without changing your
// custom settings, run the `zed: Open Default Settings` command
// from the command palette
{
"ui_font_size": 14,
"buffer_font_size": 12,
"theme": {
"mode": "system",
"light": "One Light",
"dark": "monokai Darker (Filter Spectrum)"
},
"ui_font_family": "JetBrainsMono Nerd Font Mono",
"buffer_font_family": "JetBrainsMono Nerd Font Mono",
"buffer_font_features": {
"calt": false
},
"format_on_save": "off",
"experimental.theme_overrides": {
"modified": "#ffe931",
"text.muted": "#dddddd",
"ignored": "#888888",
"surface.background": "#1d1d1d",
"tab_bar.background": "#222222",
"status_bar.background": "#222222",
"title_bar.background": "#222222",
"tab.inactive_background": "#151515",
"version_control.modified": "#265ba2",
"version_control.added": "#4fa253",
"editor.document_highlight.write_background": "#235493ff",
"editor.document_highlight.bracket_background": "#235493ff",
"editor.highlighted_line.background": "#235493ff"
},
"preview_tabs": {
"enabled": true,
"enable_preview_from_code_navigation": true
},
"lsp": {
"rust-analyzer": {
"initialization_options": {
"profile": {
"enable": true,
"output_file": "~/tmp/rust-analyzer.profile"
}
}
}
},
"languages": {
"Assembly": {
"enable_language_server": false
}
},
"diagnostics": {
"include_warnings": false,
"inline": {
"enabled": true,
"update_debounce_ms": 150,
"padding": 4,
"min_column": 0,
"max_severity": null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment