Custom Keybindings

This is the place to discuss the idea of custom keybindings.

There is also a gh issue open.

Similar topics:

2 Likes

Idea: Assign multiple keybindings to the same action, configurable both for the Vim-like “insert” mode and “normal” mode.

Explanation: I would find a great use for being able to map to a specific action multiple keybindings, where one would be activated from the regular Atuin TUI interface when in the Vim-like “insert” mode (typing modifies the searched-for command), and another from the Vim-like “normal” mode.

Specifically in my case, I would benefit from being able to quickly delete unwanted commands using Ctrl+A, D (but simplified) from the “insert” mode for a single record, but simply by pressing D in the “normal” mode repeatedly to quickly remove multiple records.

I am trying to maintain my history of commands and keep it clean. Often, I find myself lacking this feature for the “normal” mode.

I quite like how Zed handles keybindings

For example, here are my mappings

[
  {
    "context": "Editor && vim_mode == insert && !menu",
    "bindings": {
      "j j": "vim::NormalBefore"
    }
  },
  {
    "context": "Editor && vim_mode == normal && !menu",
    "bindings": {
      "space w": "workspace::Save",
      "space s t": "workspace::NewSearch",
      "space f": "file_finder::Toggle"
    }
  }
]

I do think this should happen after the settings refactor.

There’s some initial work towards refactoring here:

And I also think something like KDL would be better suited, so perhaps just a revamped config file would make sense

We’d need

  1. Sort out settings, they’re messy
  2. Abstract away inputs. The UI should handle actions, not actual key combos. Then all of our mappings can just be key → action, rather than key → implementation
  3. Figure out a nice format that can express keybindings in a flexible enough way
2 Likes

As an avid user of tmux, I like how tmux binds keys. Maybe atuin can use a similar format.

The prefix is defined like so: set -g prefix C-a but in atuin’s case, maybe something like bind prefix C-a is a better approach.

Then something like this would bind prefix + d to the action of deleting the currently selected item (as it is done right now):

bind d delete-selected
bind D delete-selected-all

P.S.: Ah, I’ve noticed that I posted w/o seeing @ellie’s comment. zed’s keybindings are also nice, except that it’s json and can lead to errors when people edit it manually. Personally I am happy with any format, but I think for most users a simple and less error-prone format would be best.

2 Likes

I was thinking more in terms of how they’re expressed and structured, less so that they use JSON. The mapping of binding → action is neat, and the context is also good! We’d need something like that to make vim mode work

Otherwise, KDL would work well imo

2 Likes

I confirm that the handling of context and the associated keybindings would satisfy all my needs.

I never used KDL or seen it used anywhere. However, I think it should work nicely in this case. But any format works for me, personally.