Ghostty + Zellij + Keychron: Fixing the macOS Option Key Mess
I’ve been setting up my remote development workflow on my Mac, using Ghostty as the terminal emulator and Zellij for session management.
Then I ran into the Option key problem.
The problem
Zellij (like tmux) uses the Alt/Meta key for bindings. I have things like:
Alt + nfor new tabsAlt + h/j/k/lfor navigationAlt + vfor splits
But on macOS, the Option key also types special characters. On my layout, Option + n produces ~ and Option + l gives me @.
So: enable macos-option-as-alt = true in Ghostty, and I can navigate Zellij but can’t type an email address. Disable it, and Zellij ignores my shortcuts.
The fix
Ghostty can treat each Option key differently. Left Option becomes Alt for commands, Right Option stays native for typing symbols.
In .config/ghostty/config:
# Left Option for Zellij, Right Option for symbols (@, ~)
macos-option-as-alt = left
Now I use my left thumb for LeftOpt + n (new tab) and my right thumb for RightOpt + n (tilde). Takes a bit of retraining, but it works.
The Keychron problem
My Keychron K3 doesn’t have a Right Option key. The key to the right of the spacebar is Right Control.
I found a fix on Reddit that remaps Right Control to Right Option at the system level.
The fix
- Create
~/Library/LaunchAgents/com.local.KeyRemapping.plist:
<!--
Put this file in ~/Library/LaunchAgents/com.local.KeyRemapping.plist to
automatically remap your keys when macOS starts.
See https://developer.apple.com/library/archive/technotes/tn2450/_index.html for
the key "usage IDs". Take the usage ID and add 0x700000000 to it before putting it
into a source or destination (HIDKeyboardModifierMappingSrc and
HIDKeyboardModifierMappingDst respectively).
The remapping makes the right control behave as a right option.
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.dgrcode.KeyRemapping</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
<string>--set</string>
<string>{"UserKeyMapping":[
{
"HIDKeyboardModifierMappingSrc": 0x7000000E4,
"HIDKeyboardModifierMappingDst": 0x7000000E6
}
]}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Now the Keychron’s Right Control key acts as Right Option. I can type symbols again.