The Computer Oracle

Emacs keybindings in zsh not working (Ctrl-A, Ctrl-E)

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Industries in Orbit Looping

--

Chapters
00:00 Emacs Keybindings In Zsh Not Working (Ctrl-A, Ctrl-E)
00:19 Accepted Answer Score 42
00:39 Answer 2 Score 9
01:16 Thank you

--

Full question
https://superuser.com/questions/523564/e...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#macos #keyboardshortcuts #zsh

#avk47



ACCEPTED ANSWER

Score 42


I got the problem solved. Looks like oh-my-zsh was overriding the default keybindings.

When I added the below line at the end of my .zshrc, CtrlE and CtrlA worked:

bindkey -e



ANSWER 2

Score 9


Generally speaking, you can find the code of a key by typing CtrlV and the key. You can then use this key with bindkey to map it to a zsh keyboard functionality (e.g. beginning-of-line).

In your specific case that would be CtrlV CtrlA and CtrlV CtrlE.

Then you can put the code in your .inputrc, the system /etc/inputrc, or your .zshrc like this:

bindkey '^A' beginning-of-line
bindkey '^E' end-of-line

This works for other keys too. For instance, I had some trouble with Home and End.

You should be able to use this trick in any terminal session : tty,