[FEATURE]: Custom TUI actions/keybinds for shell commands #4438

Open
opened 2026-02-16 17:43:47 -05:00 by yindo · 1 comment
Owner

Originally created by @magnusrodseth on GitHub (Jan 8, 2026).

Originally assigned to: @thdxr on GitHub.

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:

  1. Add custom entries to the Ctrl+P command palette that execute TUI actions
  2. 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% lazygit

What 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+P command 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+P command 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

  1. Tool integration - Launch external TUI tools (lazygit, btop, yazi, etc.) without leaving OpenCode
  2. Workflow efficiency - Quick access to frequently-used commands
  3. Discoverability - Commands visible in Ctrl+P palette
  4. 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.

Originally created by @magnusrodseth on GitHub (Jan 8, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] 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: 1. Add custom entries to the `Ctrl+P` command palette that execute TUI actions 2. 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](https://github.com/code-yeongyu/oh-my-opencode)), the ideal command would be: ```bash tmux popup -E -w 90% -h 90% lazygit ``` ### What I tried **1. Custom command in `opencode.json`:** ```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+P` command 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: ```json { "command": { "lazygit": { "type": "shell", "execute": "tmux popup -E -w 90% -h 90% lazygit", "description": "Open lazygit in tmux popup" } } } ``` These would: - Appear in `Ctrl+P` command palette - Execute immediately without AI involvement - Not create chat messages ### Option B: Custom keybinds for shell commands Allow keybinds to execute arbitrary commands: ```json { "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 1. **Tool integration** - Launch external TUI tools (lazygit, btop, yazi, etc.) without leaving OpenCode 2. **Workflow efficiency** - Quick access to frequently-used commands 3. **Discoverability** - Commands visible in `Ctrl+P` palette 4. **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.
yindo added the discussion label 2026-02-16 17:43:47 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 8, 2026):

This issue might be a duplicate or related to existing issues. Please check:

  • #5904: Users ought to be able to bind custom slash commands to keystrokes
  • #5305: Plugin Hook for Instant TUI Commands
  • #4997: Keybinds (pinned keybinds documentation)
  • #5082: Allow shell commands in the frontmatter
  • #4839: Droid-like custom slash commands in arbitrary languages using shebang lines
  • #4683: Allow multiple shell setups and allow switching them at runtime via TUI command

Also, for keybind-related issues, please check our pinned keybinds documentation: #4997

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 8, 2026): This issue might be a duplicate or related to existing issues. Please check: - #5904: Users ought to be able to bind custom slash commands to keystrokes - #5305: Plugin Hook for Instant TUI Commands - #4997: Keybinds (pinned keybinds documentation) - #5082: Allow shell commands in the frontmatter - #4839: Droid-like custom slash commands in arbitrary languages using shebang lines - #4683: Allow multiple shell setups and allow switching them at runtime via TUI command Also, for keybind-related issues, please check our pinned keybinds documentation: #4997 Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4438