'fish shell: ctrl-p is not working but ARROW UP is [closed]

I recently installed various fisher plugins and updated to fish 3.4.1 and now "ctrl-p" does not cycle through my commands anymore, but ARROW UP is still working. When I switch to the bash shell, ctrl-p is working. I observe the same behaviour in the gnome terminal and kitty terminal. I have no clue what the problem is and would appreciate a lot if someone could help me, thanks in advance!



Solution 1:[1]

It appears one of your plugins rebound ctrl-p.

In general, to find out what a key sequence is bound to, you need to:

  1. Figure out what the key sequence is by starting fish_key_reader and pressing it
  2. Pass that to bind

So, you run fish_key_reader, which tells you:

bind \cP 'do something'

That means ctrl-p sends \cP.

So, we ask what \cP is bound to:

bind \cP

which by default gives us

bind --preset \cp up-or-search

(yes, the case is indeed irrelevant after a \c as \cp and \cP encode the same).

And if you had bound something differently, it might print multiple lines like

bind --preset \cp up-or-search
bind \cp 'echo oops'

What can also happen here is that one of your plugins enabled vi-mode (this can happen even for things you might think are entirely unrelated, for instance there's at least one semi-popular prompt that believes it's entitled to enable it).

In that case, bind \cP will output nothing, and you can also ask bind -M insert \cP to ask what ctrl-p is bound to in insert mode.

To disable vi-mode and go back to the default emacs-inspired bindings (where that binding for ctrl-p originated), run fish_default_key_bindings.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 faho