-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Summary
Allow users to define custom keybinds or command palette entries that execute shell commands directly as TUI actions, rather than sending them as prompts to the AI.
Problem
Currently, OpenCode's command config only creates chat commands - slash commands that send prompts to the AI and appear in the conversation. There's no way to:
- Add custom entries to the
Ctrl+Pcommand palette that execute TUI actions - Bind a keybind to execute a shell command directly (bypassing the AI)
Use Case: Launching lazygit
I want to open lazygit from within OpenCode using a keybind or the command palette. Since I run OpenCode inside tmux (via oh-my-opencode), the ideal command would be:
tmux popup -E -w 90% -h 90% lazygitWhat I tried
1. Custom command in opencode.json:
{
"command": {
"lazygit": {
"template": "!tmux popup -E -w 90% -h 90% lazygit",
"description": "Open lazygit"
}
}
}Result: This creates a /lazygit slash command, but:
- It sends
!tmux popup...as a message to the AI - It doesn't appear in the
Ctrl+Pcommand palette as a TUI action - It pollutes the chat context
2. Custom keybind:
There's no keybind option to execute a shell command. The keybinds config only maps to predefined TUI actions.
Proposed Solution
Option A: Custom TUI commands
Allow command entries to specify type: "tui" or similar to indicate they should execute directly:
{
"command": {
"lazygit": {
"type": "shell",
"execute": "tmux popup -E -w 90% -h 90% lazygit",
"description": "Open lazygit in tmux popup"
}
}
}These would:
- Appear in
Ctrl+Pcommand palette - Execute immediately without AI involvement
- Not create chat messages
Option B: Custom keybinds for shell commands
Allow keybinds to execute arbitrary commands:
{
"keybinds": {
"custom_lazygit": {
"key": "ctrl+g",
"execute": "tmux popup -E -w 90% -h 90% lazygit"
}
}
}Option C: Both
Support both approaches for maximum flexibility.
Benefits
- Tool integration - Launch external TUI tools (lazygit, btop, yazi, etc.) without leaving OpenCode
- Workflow efficiency - Quick access to frequently-used commands
- Discoverability - Commands visible in
Ctrl+Ppalette - Clean context - No chat pollution from utility commands
Additional Context
This is similar to how editors like VS Code allow custom keybinds to run terminal commands, or how Neovim users integrate lazygit via lazygit.nvim. Since OpenCode is becoming a "terminal hub" for many developers (especially with oh-my-opencode rise in popularity), native support for TUI action keybinds would be valuable.