Skip to content

Conversation

@ariane-emory
Copy link
Contributor

@ariane-emory ariane-emory commented Dec 21, 2025

feat: add keybind support for custom slash commands Allow users to bind custom slash commands to keystrokes by adding
entries to the keybinds config with keys starting with '/'. When one of these keys is struck, command is inserted before the text in the main prompt text input box and then that input is submitted, allowing arguments to be passed to custom slash commands as normal (e.e., if the text input box contains foo "bar" and a key is struck to trigger /my-command, then /my-command foo "bar" is submitted`).

If the slash command referenced by a keybinding does not exist when they key is struck (e.g., if the command's .md file was deleted while opencode was running) this is handled safely, and a toast is displayed indicating that no such command existsts.

I've been using this feature all week in my personal fork and it has made a truly tremendous difference in my workflow, i really think that this one is a killer feature.

Changes:

  • Update Config.Keybinds schema to accept arbitrary keys using catchall
  • Add keyboard handler in TUI to match and execute command keybinds
  • Regenerate TypeScript SDK to reflect updated KeybindsConfig type

When a command keybind is pressed, the prompt is set to the command
text and immediately submitted, executing the custom command.

Example usage in config.json:

{
  "$schema": "https://opencode.ai/config.json",
  "keybinds": {
    "/commit-and-push--using-big-pickle": "ctrl+alt+c",
    "/fetch-and-pull-all-branches--using-glm-4.6": "ctrl+alt+f",
    "/merge-dev-into-branch-resolve-conflicts-and-push--using-copilot-sonnet": "ctrl+alt+m",
    "/integrate-the-branches-listed-in-yoinklistmd--using-antigravity-opus": "ctrl+alt+i",
    "/integrate-the-branches-listed-in-yoinklistmd--using-copilot-opus": "ctrl+alt+shift+i",
  }
}

Resolves #5904.

Allow users to bind custom slash commands to keystrokes by adding
entries to the keybinds config with keys starting with '/'.

Changes:
- Update Config.Keybinds schema to accept arbitrary keys using catchall
- Add keyboard handler in TUI to match and execute command keybinds
- Regenerate TypeScript SDK to reflect updated KeybindsConfig type

When a command keybind is pressed, the prompt is set to the command
text and immediately submitted, executing the custom command.

Example usage in config.json:
{
  "keybinds": {
    "/my-command": "ctrl+shift+m"
  }
}

Resolves: #47
Add null checks to prevent TypeScript errors when keybind values
are undefined in the config.
When a command keybind is triggered, preserve any existing text in the
prompt input box and append it as arguments to the command.

Example: If the prompt contains 'blah blah abrahadabra' and the user
presses a key bound to /foo, the prompt becomes '/foo blah blah abrahadabra'
before submission, passing the original text as arguments to the command.

This makes command keybinds more flexible and allows users to quickly
apply commands to text they've already typed.
@ariane-emory ariane-emory changed the title Feat/keybindable commands feat(tui): Allow keybinding of custom slash commands Dec 21, 2025
@ariane-emory ariane-emory changed the title feat(tui): Allow keybinding of custom slash commands feat(tui): Allow keybinding of custom slash commands (resolves #5904) Dec 21, 2025
@ariane-emory ariane-emory force-pushed the feat/keybindable-commands branch from 3cb88f0 to 1879881 Compare December 24, 2025 19:24
@ariane-emory ariane-emory marked this pull request as draft December 24, 2025 19:28
@ariane-emory ariane-emory force-pushed the feat/keybindable-commands branch from 1879881 to 6945498 Compare December 24, 2025 19:42
@ariane-emory ariane-emory marked this pull request as ready for review December 24, 2025 19:43
@ariane-emory ariane-emory marked this pull request as draft December 24, 2025 19:44
@ariane-emory ariane-emory marked this pull request as ready for review December 24, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Users ought to be able to bind custom slash commands to keystrokes.

1 participant