Native macOS right-click context menu for Kitty terminal.
Kitty doesn't have a built-in context menu. This adds one using a compiled Swift binary that renders a native NSMenu popup at your mouse cursor.
"Copy" only appears when clipboard has content. Separator line between clipboard actions and terminal actions.
Right-click
→ kitty fires: launch --type=background context_menu.sh
→ context_menu.sh calls compiled Swift binary (context_menu_bin)
→ Swift binary renders native NSMenu at mouse cursor
→ User clicks menu item → choice returned via temp file
→ context_menu.sh executes action via kitty remote control (kitty @)
Key design decisions:
launch --type=background— menu runs in separate process, doesn't block kittycopy_on_select clipboard— text copied to clipboard the moment you select it, no race condition with right-click clearing selection- Compiled Swift binary — instant popup, no interpreter startup delay
discard_eventon right press — prevents kitty's default "extend selection" from clearing your selection before the menu appears- Kitty remote control via unix socket — actions (paste, clear, new tab) executed reliably through
kitty @
- macOS (uses NSMenu, Cocoa framework)
- Kitty 0.35+ (needs
allow_remote_control,listen_on,copy_on_select,launch --type=background) - Xcode Command Line Tools (
swiftccompiler)
git clone https://github.com/prthmgoyl/kitty-context-menu.git
cd kitty-context-menu
chmod +x install.sh
./install.shThen restart kitty (Cmd+Q, reopen).
cd kitty-context-menu
chmod +x uninstall.sh
./uninstall.shIf you prefer to set it up manually:
- Copy
context_menu.shandcontext_menu.swiftto~/.config/kitty/ - Compile:
swiftc ~/.config/kitty/context_menu.swift -o ~/.config/kitty/context_menu_bin -framework Cocoa - Make executable:
chmod +x ~/.config/kitty/context_menu.sh - Add to
~/.config/kitty/kitty.conf:
allow_remote_control socket-only
listen_on unix:/tmp/kitty-sock
copy_on_select clipboard
mouse_map right press ungrabbed discard_event
mouse_map right release ungrabbed launch --type=background ~/.config/kitty/context_menu.sh- Restart kitty
Edit context_menu.sh to add/remove/rename menu items. The ITEMS variable is a comma-separated list. Use --- for separator lines.
# Example: add "Open Config" item
ITEMS="Copy,Paste,---,Copy All,New Tab,Open Config,Clear Screen"
# In the case statement:
"Open Config")
kitty @ --to "$KITTY_SOCKET" action edit_config_file
;;No recompilation needed for menu item changes — only context_menu.sh is edited. Recompile Swift binary only if you change context_menu.swift (popup rendering logic).
- macOS only — NSMenu is a Cocoa API, no Linux/Windows support
- No visual "Select All" — kitty doesn't support programmatic text selection. "Copy All" copies everything to clipboard instead
- Popup appearance — follows your macOS system theme (light/dark), not kitty's color scheme
- Multiple kitty instances — socket discovery uses
ls /tmp/kitty-sock*and picks the first one. If you run multiple kitty instances, the menu may target the wrong one
MIT
