Emacs keybindings in zsh not working (Ctrl-A, Ctrl-E)
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
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,