# Default key binding changes

**URL:** <https://forum.atuin.sh/t/default-key-binding-changes/41>\
**Category:** General\
**Created:** [January 5, 2024, 12:33pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41 "2024-01-05T12:33:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [January 5, 2024, 12:33pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/1 "2024-01-05T12:33:27Z")

</div>

Atuin currently has editing key bindings that are fairly similar to GNU Readline, which in turn is fairly similar to emacs

You can see a full list here: [GNU Readline - Wikipedia](https://en.wikipedia.org/wiki/GNU_Readline)

This is good for new users, as it ensures that their editing experience is consistent

However, it has made future features a bit trickier to implement. Looking through that list, most ctrl- bindings have been taken already for editing. Many of these bindings are equivalent to others. For example, ctrl-p → up arrow.

While I can appreciate the familiarity of an editing experience, I’d rather avoid making our own keybindings more complicated and emacs-y

I’d also love to be able to use ctrl-i to open an inspector for the currently selected command - but readline has that as another way to type “tab”.

Otherwise, ctrl-h for… help. But again, readline has that as another way to press backspace.

I’m very tempted to claim some of those for our own uses, but inevitably that will cause friction for some users. Other modifier keys lack consistent and reliable support - such as alt, super, cmd, etc.

In all likelihood, I’ll be breaking some of our readline parity in favour of more flexibility for development.

We do have an open issue for custom key bindings

> <https://github.com/atuinsh/atuin/issues/193>
>
> I'm using this and liking it. Thank you!
> 
> Just for the record, I'd like to use… different key bindings than the default arrows.

but even when that is done, the defaults may feel a bit alien to some people.

Just creating this as a discussion to see if anyone has feedback or suggestions 😊

One potential option is leaving as-is, but adding `ctrl-shift-<char>` to be our bindings, though these are not supported by all terminals

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [January 5, 2024, 1:08pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/2 "2024-01-05T13:08:28Z")

</div>

> [@ellie](#):
>
> One potential option is leaving as-is, but adding `ctrl-shift-<char>` to be our bindings, though these are not supported by all terminals

Support for this sort of modifier combo: [feat: enable enhanced keyboard mode by ellie · Pull Request #1505 · atuinsh/atuin · GitHub](https://github.com/atuinsh/atuin/pull/1505)

Terminal support is limited, unfortunately

---

<div class="post-metadata">

**Author:** ![Adda](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/adda/32/36_2.png) [@Adda](https://forum.atuin.sh/u/Adda)\
**Post date:** [January 5, 2024, 5:40pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/3 "2024-01-05T17:40:28Z")

</div>

> [@ellie](#):
>
> Other modifier keys lack consistent and reliable support - such as alt, super, cmd, etc.

I think this is a real shame as there could be `Alt-` shortcuts for Atuin’s own use and `Ctrl-` shortcuts following the GNU Readline shortcuts.

I am not sure, however, how many people even know about them and use the GNU Readline shortcuts. I, personally, don’t even know they exist. And don’t plan on using them now that I heard about them. But I have no idea what the general knowledge about these shortcuts and their frequency of use is among Atuin users.

That being said, even if I found the GNU Readline shortcuts useful, I would personally be for primarily focussing on Atuin’s own shortcuts and using, for example, the `ctrl-shift-` versions for GNU Readline. They would be available on only some terminals, then, but at least the Atuin shortcuts would be available everywhere.

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [January 6, 2024, 4:28pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/4 "2024-01-06T16:28:05Z")

</div>

Ok perfect! I was thinking this might be the case. It seems like a low % of people even know about them in the first place

---

<div class="post-metadata">

**Author:** ![Adda](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/adda/32/36_2.png) [@Adda](https://forum.atuin.sh/u/Adda)\
**Post date:** [January 6, 2024, 6:37pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/5 "2024-01-06T18:37:00Z")

</div>

Especially when every other CLI application and terminal emulator breaks these rules, anyway, I presume.

It can be great for those who know and use them, so some support (with `Ctrl-Shift-`, for example) could still help those people, but I would personally not bend the desired design only to have a first-class support for GNU Readline shortcuts.

---

<div class="post-metadata">

**Author:** ![pdecat](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/pdecat/32/21_2.png) [@pdecat](https://forum.atuin.sh/u/pdecat)\
**Post date:** [January 6, 2024, 7:02pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/6 "2024-01-06T19:02:24Z")

</div>

How about introducing a command mode _à la_ vi?

---

<div class="post-metadata">

**Author:** ![Adda](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/adda/32/36_2.png) [@Adda](https://forum.atuin.sh/u/Adda)\
**Post date:** [January 6, 2024, 9:11pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/7 "2024-01-06T21:11:08Z")

</div>

That could be a great solution, too. An advantage would be that the command modes could be easily extended with other modes for futher functionality. But is there (or will be) any new functionality that could use such command modes? The disadvantage is having to implement the whole command mode logic for possibly only one feature (GNU Readline-like shortcuts) that maybe not many people use.

Another problem with this approach in my opinion is that one would presumably want to use both Atuin’s own shortcuts and GNU Readline-like shortcuts interchangeably in quick successions, not use all the GNU Readline shortcuts, then switch the mode, and only then use all Atuin’s shortcuts, and possibly switch again. There would be way too much switching to shortcuts ratio, I think.

But maybe I am wrong. It is hard to say when I have never used the GNU Readline shortcuts myself. This is the impression I got from looking at the shortcuts for GNU Readline.

What do you think about these concerns? In addition, do you have an idea for something that could utilize the command modes except for the shortcuts for GNU Readline?

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [January 7, 2024, 5:10pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/8 "2024-01-07T17:10:02Z")

</div>

> [@pdecat](#):
>
> How about introducing a command mode _à la_ vi?

I’d love to! It can’t be the default though 😕 Much as I wish it to be the case, most people are unfamiliar with vi keybindings

> [@Adda](#):
>
> do you have an idea for something that could utilize the command modes except for the shortcuts for GNU Readline?

Sure - mostly future functionality, but even things like deleting history, exploring history, switching search/filter/etc modes… It would make them more useful.

---

<div class="post-metadata">

**Author:** ![akinomyoga](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/akinomyoga/32/69_2.png) [@akinomyoga](https://forum.atuin.sh/u/akinomyoga)\
**Post date:** [January 17, 2024, 10:42am UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/9 "2024-01-17T10:42:41Z")

</div>

Maybe this was already mentioned elsewhere, but the distinction between C-i vs tab and C-h vs backspace has a subtlety in the terminal’s support. There is the same issue with C-[ vs esc, C-m and return/enter.

First of all, the keyboard inputs return, tab, esc, and backspace are all encoded by corresponding control characters in the terminal-to-host stream historically. The keys modified by Control, C-\<ascii\>, are also encoded by corresponding control characters. This is the conventional rule shared by all the terminals. For this reason, they are indistinguishable within the _standard keyboard protocol_ of the terminals. Also, this is not the area covered by `termcap` and `terminfo`.

Some of the terminals support extended keyboard protocols, such as XTerm’s `modifiedOtherKeys` and kitty’s keyboard protocol, so those keys may be distinguished in some terminals. However, not all the terminals support such an extended protocol. In particular, we can hardly expect the system consoles to introduce the support for an extended protocol.

This means that if we assign different functions to those pairs of keys, some of the Atuin features would be impossible to access from some environments. Or, it might cause an unexpected action in a system console. The shell experience would be a part of muscle memory for heavy users. Once one gets used to Atuin, one might not be able to live without Atuin. In such a case, the limitation to the environment can be frustrating.

Some of the extra modifiers (super s-, hyper H-, and even alt A- which is distinct from meta) seem to be suggested, but these are actually historical ones, which already disappeared effectively. We can find fewer terminals supporting them than the ones with the support for the extended keyboard protocols.

I’d suggest sticking with the keys available in the standard protocol for the default keybindings. I think we don’t have to strictly preserve all the Readline bindings, and we can also assign functions to key combinations. The keybindings do not need to be a single keypress.

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [January 18, 2024, 5:57pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/10 "2024-01-18T17:57:45Z")

</div>

Thanks for clearing that up!

> [@akinomyoga](#):
>
> I think we don’t have to strictly preserve all the Readline bindings, and we can also assign functions to key combinations. The keybindings do not need to be a single keypress.

100%.

---

<div class="post-metadata">

**Author:** ![tessus](https://forum-cdn.atuin.sh/letter_avatar_proxy/v4/letter/t/ee59a6/32.png) [@tessus](https://forum.atuin.sh/u/tessus)\
**Post date:** [February 27, 2024, 8:40pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/12 "2024-02-27T20:40:10Z")

</div>

I think a prefix system like screen or tmux uses would be great. I was an avid screen user until tmux came around, which is why I changed the default meta in tmux from `C-b` to `C-a` 😉

The number of possible shortcuts increases at least 3-fold.

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [March 13, 2024, 4:38pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/13 "2024-03-13T16:38:05Z")

</div>

Agreed on the prefixes. I wanted to avoid it originally, but I think it’s the least-bad option

I added initial support here

> <https://github.com/atuinsh/atuin/pull/1875>
>
> This means we can prefix all Atuin keybindings with ctrl-a, totally eliminating …the risk of collisions with readline/etc.
> 
> The only downside here is that ctrl-a no longer moves to the beginning of the line, as in readline.
> 
> \## Checks
> \- \[\] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle
> \- \[\] I have checked that there are no existing pull requests for the same thing

It uses ctrl-a.

I’ll add some config for that later

---

<div class="post-metadata">

**Author:** ![tfh-cri](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/tfh-cri/32/304_2.png) [@tfh-cri](https://forum.atuin.sh/u/tfh-cri)\
**Post date:** [June 17, 2024, 8:50pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/14 "2024-06-17T20:50:48Z")

</div>

Is there a longer-term intent to make the prefix override of Ctrl-A toggleable or customisable (ideally, that could land prior to the “configure all the bindings” ongoing feature plans)?

I’ve ended up in this thread after trying to figure out why the binding mysteriously stopped working recently, and turns out it was intentional (slight sidenote, the docs at [Key Binding | Atuin Docs](https://docs.atuin.sh/configuration/key-binding/) still mention the older bindings, not sure if it warrants an actual bug report?).

I like the prefix idea as a general solution to the limited keymap capability problem, my only quibble is that it’s one I use an awful lot! 🙂

Having had a quick poke around in [atuin/crates/atuin/src/command/client/search/interactive.rs at 88633b8994437180afdd66068cc2c8f02aea1db1 · atuinsh/atuin · GitHub](https://github.com/atuinsh/atuin/blob/88633b8994437180afdd66068cc2c8f02aea1db1/crates/atuin/src/command/client/search/interactive.rs#L297), I think this is now causing `Ctrl-a, d` to (permanently?) delete the selected item from the history DB? If that is the case, I can see myself accidentally deleting random items when the muscle memory kicks in, which definitely doesn’t seem ideal.

---

<div class="post-metadata">

**Author:** ![tessus](https://forum-cdn.atuin.sh/letter_avatar_proxy/v4/letter/t/ee59a6/32.png) [@tessus](https://forum.atuin.sh/u/tessus)\
**Post date:** [June 17, 2024, 11:05pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/15 "2024-06-17T23:05:48Z")

</div>

> [@tfh-cri](#):
>
> `Ctrl-a, d` to (permanently?) delete the selected item from the history DB? If that is the case, I can see myself accidentally deleting random items when the muscle memory kicks in, which definitely doesn’t seem ideal.

I don’t think I understand. What muscle memory would be `Ctrl-a d`? This has never been used in atuin before.

The only thing that could be an issue is using tmux where the prefix has also been changed to Ctrl-a. (I am actually doing this.) But I have learned for many other utils that use ctrl-a as a prefix (or key combination) or for nested tmux sessions to use the proper escaping.

I believe that this prefix/key combination is perfectly fine for deleting a command. Peviously I had to open the inspector to do so. This is much easier to handle.

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [June 18, 2024, 9:25am UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/16 "2024-06-18T09:25:06Z")

</div>

hey! welcome to the forum

It’s currently not configurable, but will be in the next release. I just merged

> <https://github.com/atuinsh/atuin/pull/2157>
>
> \## Checks
> \- \[\] I am happy for maintainers to push small adjustments to this PR…, to speed up the review cycle
> \- \[\] I have checked that there are no existing pull requests for the same thing

---

<div class="post-metadata">

**Author:** ![tfh-cri](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/tfh-cri/32/304_2.png) [@tfh-cri](https://forum.atuin.sh/u/tfh-cri)\
**Post date:** [June 18, 2024, 10:03am UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/17 "2024-06-18T10:03:56Z")

</div>

> [@tessus](#):
>
> I don’t think I understand. What muscle memory would be `Ctrl-a d`? This has never been used in atuin before.

Sorry, looking back I wasn’t as clear as I was hoping.

My issue is that my muscle memory for “go to start of line, and add a missing D” (which I’ve come to expect to work in anything I’ve mentally categorised as “readline-ish”, which until recently included Atuin) is now bound to a destructive action, and from a quick experiment there doesn’t seem to be a huge amount of visual feedback or undo ability to indicate that you just deleted a history item.

> [@tessus](#):
>
> The only thing that could be an issue is using tmux where the prefix has also been changed to Ctrl-a. (I am actually doing this.) But I have learned for many other utils that use ctrl-a as a prefix (or key combination) or for nested tmux sessions to use the proper escaping.

GNU Screen uses Ctrl-A as a prefix key by default, which presents exactly the problem you’re describing, but as a default on a (probably still fairly popular?) utility likely to be in common usage with atuin.

The prefix/passthrough is (IMO) more of a workaround than a solution, since you now have to remember what prefixes are necessary in which situations, and internalise that so you don’t get it wrong.

---

<div class="post-metadata">

**Author:** ![tfh-cri](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/tfh-cri/32/304_2.png) [@tfh-cri](https://forum.atuin.sh/u/tfh-cri)\
**Post date:** [June 18, 2024, 10:20am UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/18 "2024-06-18T10:20:48Z")

</div>

> [@ellie](#):
>
> hey! welcome to the forum
> 
> It’s currently not configurable, but will be in the next release.

Hey, thanks for the welcome, and also for such a speedy patch!

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [June 18, 2024, 1:20pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/19 "2024-06-18T13:20:48Z")

</div>

> [@tfh-cri](#):
>
> Hey, thanks for the welcome, and also for such a speedy patch!

You’re welcome! Hope everything else is working ok for you?

> [@tfh-cri](#):
>
> The prefix/passthrough is (IMO) more of a workaround than a solution

I’m not a fan of the prefix tbh, but given that matching readline is so difficult it came about as a reasonable alternative. If we’d used almost any other key, we’d run into similar issues with _someone’s_ muscle memory somewhere, as readline uses them all

---

<div class="post-metadata">

**Author:** ![tfh-cri](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/tfh-cri/32/304_2.png) [@tfh-cri](https://forum.atuin.sh/u/tfh-cri)\
**Post date:** [June 18, 2024, 4:25pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/20 "2024-06-18T16:25:06Z")

</div>

> [@ellie](#):
>
> I’m not a fan of the prefix tbh, but given that matching readline is so difficult it came about as a reasonable alternative. If we’d used almost any other key, we’d run into similar issues with _someone’s_ muscle memory somewhere, as readline uses them all

I’m actually fine with the idea of prefix keys, especially for less commonly used functions – there just aren’t enough distinguishable keys otherwise.

The “workaround” bit was about `C-a, a` being, in effect `C-a` (beginning-of-line). i.e. having the original function as an item in the prefix keymap, so its still accessible. It definitely can work, and is better than nothing at all so you can still reach that function, but can be pretty jarring for the slower-to-adapt amongst us 🙂

My vote, insofar as I have one, would be for `C-x` as a prefix, since that’s where readline traditionally dumped all its rarely used functions. (Emacs reserves `C-c` as a specific user-customisable keymap, but that’s a bit too wacky given the much more common “cancel/send sigint” and/or “copy to clipboard” uses)

> [@ellie](#):
>
> You’re welcome! Hope everything else is working ok for you?

I’ve just built it locally and upon testing, I think to actually do what I want it’ll need to reinstate the original `emacs` keymap `C-a` binding

I think that’ll be fine because if the prefix-check will eat the keypress before it gets that far if its left at the default of `C-a`.

```auto
KeyCode::Char('a') if ctrl => self.search.input.start(),

```

(i.e.: revert the removal from the original prefix impl in `b04fc471deb923937b8ef9aab2f39301f8457894`)

I can have a stab at submitting as PR if that would be helpful?

---

<div class="post-metadata">

**Author:** ![tessus](https://forum-cdn.atuin.sh/letter_avatar_proxy/v4/letter/t/ee59a6/32.png) [@tessus](https://forum.atuin.sh/u/tessus)\
**Post date:** [June 18, 2024, 4:38pm UTC](https://forum.atuin.sh/t/default-key-binding-changes/41/21 "2024-06-18T16:38:46Z")

</div>

> [@tfh-cri](#):
>
> My issue is that my muscle memory for “go to start of line, and add a missing D” (which I’ve come to expect to work in anything I’ve mentally categorised as “readline-ish”, which until recently included Atuin) is now bound to a destructive action, and from a quick experiment there doesn’t seem to be a huge amount of visual feedback or undo ability to indicate that you just deleted a history item.

Ok, this makes sense then.

> [@tfh-cri](#):
>
> The prefix/passthrough is (IMO) more of a workaround than a solution, since you now have to remember what prefixes are necessary in which situations, and internalise that so you don’t get it wrong.

Unfortunately this is not limited to atuin or shortcuts. This is something that you have to deal with in other situations as well. e.g. nesting, escaping, quoting, …

> [@tfh-cri](#):
>
> reinstate the original `emacs` keymap `C-a` binding

This can only be done if Ctrl-a is not used. Thus your PR needs to check that the prefix is not Ctrl-a.

[Next page](https://forum.atuin.sh/t/default-key-binding-changes/41.md?page=2)
