-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat(tui): Allow keybinding of custom slash commands (resolves #5904) #5903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ariane-emory
wants to merge
20
commits into
sst:dev
Choose a base branch
from
ariane-emory:feat/keybindable-commands
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+57
−3
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
3cb88f0 to
1879881
Compare
1879881 to
6945498
Compare
…pencode into feat/keybindable-commands
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.mdfile 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:
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.