feat: Add new custom keybinding system for search TUI#3127
Open
BinaryMuse wants to merge 7 commits intomainfrom
Open
feat: Add new custom keybinding system for search TUI#3127BinaryMuse wants to merge 7 commits intomainfrom
BinaryMuse wants to merge 7 commits intomainfrom
Conversation
Contributor
Greptile OverviewGreptile SummaryReplaces 450-line hardcoded key handling with declarative keymap system. Users can now fully customize TUI shortcuts via Key Changes:
Architecture: All files are well-structured with clear separation of concerns. No issues found. Important Files Changed
|
Member
Author
|
@ellie I'm feeling pretty happy with this |
Member
Author
|
Updated to include cmd/win/super key support, with strong caveats in the docs. |
32748c6 to
08a6b5e
Compare
ellie
approved these changes
Feb 5, 2026
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
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.
Summary
Replaces the hardcoded ~450-line key handling block in
interactive.rswith a declarative, conditional keybinding table system. Users can now fully customize TUI keyboard shortcuts via[keymap]in their config, using simple bindings or conditional rules with boolean expressions.keybindingsmodule with key parsing, actions, conditions, keymaps, and default definitions[keymap.emacs],[keymap.vim-normal],[keymap.vim-insert],[keymap.inspector], and[keymap.prefix]config sectionswhenclauses (e.g.{ when = "cursor-at-start", action = "exit" }) and boolean expressions (&&,||,!, parentheses)Acceptintoaccept(execute immediately) andreturn-selection(place on command line without executing), giving users explicit control over whatenter_acceptpreviously toggled at runtimereturn-selection-Nactions for numbered selection without executing[keys]configs continue to work;[keymap]takes precedence when presentdocs/docs/configuration/advanced-key-binding.mdMotivation
The old key handling code was a single monolithic match block that was difficult to extend and impossible for users to customize beyond a few boolean flags (
scroll_exits,exit_past_line_start, etc.). Feature requests for custom keybindings were a recurring source of GitHub issues.This system lets users express any combination of key + condition + action without needing code changes. The old
[keys]boolean flags become just specific instances of the more general conditional binding pattern.Architecture
New modules (
crates/atuin/src/command/client/search/keybindings/):key.rsSingleKey,KeyInputwith parsing and displayactions.rsActionenum with kebab-case serdeconditions.rsConditionAtom,ConditionExprwith recursive descent parserkeymap.rsKeymap,KeyBinding,KeyRulewith conditional resolutiondefaults.rsKeymapSetwith all five default keymaps + config overlay logicModified files:
interactive.rshandle_search_input/handle_search_key_inputwith resolver+executor pipeline; addedexecute_actionmethodinspector.rsinput()function (absorbed into keymap system)settings.rsKeymapConfig,KeyBindingConfig,KeyRuleConfigserde types;keymapfield onSettingsConfig format
Test plan
cargo test -p atuin -- keybindings)cargo test -p atuin -- interactive::tests)cargo run -- search -iin emacs mode — verify default bindings workcargo run -- search -iin vim mode — verify normal/insert mode switching,gg,G,hjkl,ctrl-u/d/b/fctrl-o) — verify navigation and delete[keymap.emacs]override to config, verify it takes effect[keys]config with no[keymap], verify backward compat[keys]+[keymap]together, verify[keys]is ignored with warningResolves #193
Resolves #2005
Resolves #2124
Resolves #2448
Resolves #2555
Resolves #2830
Resolves #2993
Resolves #2745
Resolves #2486
Resolves #2381
Resolves #2548
Resolves #2733
Probably resolves #2876
Other issues that may be affected, but likely not fixed: #1392, #1192, #2573, #3087, #2764, #2786