Global hotkey to toggle cmux with Hammerspoon
I switched to cmux as my main terminal. It is a Ghostty-based macOS terminal built for AI coding agents, with vertical tabs, split panes, and notifications. I like it a lot. It is still missing one feature I treat as essential: a global hotkey to summon the terminal from anywhere.
Why Ctrl+Space
Ghostty, Windows Terminal, and iTerm2 all let you bind a system-wide hotkey that shows or hides the terminal. Press once to bring it up. Press again to hide it. That beats cycling through Cmd+Tab or Alt+Tab.
I stuck with Ctrl+Space because:
- easy one-hand hit near the home row
- few app conflicts on my machine (I turned off the old macOS input-source binding)
- same combo I already used on Ghostty, Windows Terminal, and iTerm
cmux has no setting for this. There is an open issue for customizable keybindings. Terminal keys come from Ghostty config, cmux-specific shortcuts live in Settings, and neither path covers a global summon hotkey.
The Hammerspoon solution
Since I already use Hammerspoon for other macOS automation, adding a global hotkey for cmux is just a few lines in ~/.hammerspoon/init.lua:
hs.hotkey.bind({"ctrl"}, "space", function()
local app = hs.application.find("cmux")
if app then
if app:isFrontmost() then
app:hide()
else
app:activate()
end
else
hs.application.launchOrFocus("cmux")
end
end)
This does three things depending on the current state:
- cmux is focused - hides it, sending you back to whatever app you were using.
- cmux is running but not focused - brings it to the front.
- cmux is not running - launches it.
After adding the snippet, reload Hammerspoon (click the menu bar icon and select “Reload Config”, or set up a reload hotkey).
Works with any app
There’s nothing cmux-specific about this pattern. You can use the same snippet for any app by replacing "cmux" with the app’s process name. To find the exact process name, run this in the Hammerspoon console:
hs.fnutils.each(hs.application.runningApplications(), function(app)
print(app:name())
end)
Or check Activity Monitor.