Skip to content

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

@magnusrodseth

Description

@magnusrodseth

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.

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions