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.

@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
- DialogSelect: Add prefix-first alphabetical sorting to filtered results
- Remove commented-out sort in grouped memo since sorting is now done in filtered()
- DialogModel: Add sortWithPrefixFirst helper for custom filtering logic
- Preserve 'Free first' ordering within filtered groups
- Ensures consistent alphabetical ordering in /theme and /models menus
Resolved merge conflict in dialog-model.tsx by combining:
- Advanced prefix-first sorting with 'Free first' ordering from fix branch
- Recents limit to 5 items from dev branch
Both filtering and sorting improvements are now preserved.
…ory/opencode into fix/modal-menus-filtered-order
…ory/opencode into fix/modal-menus-filtered-order
@fwang fwang requested a review from adamdotdevin as a code owner January 9, 2026 06:32
@ariane-emory ariane-emory force-pushed the feat/keybindable-commands branch 2 times, most recently from 04ba91e to 239fed6 Compare January 9, 2026 09:51
Replace Keybinds schema .strict() with .catchall() + .superRefine() to:
- Allow custom keybind keys that start with '/' (slash command names)
- Reject unknown keys that don't start with '/' with a clear error message
- Preserve validation for all predefined keybind names

Add tests for slash command keybind acceptance and rejection of invalid keys.
Regenerate SDK types to include index signature for custom keybinds.
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