Keyboard bindings from bash to zsh

keyboard shortcutszsh

I have the following entries on my .inputrc for bash:

"\C-p": history-search-backward
"\C-n": history-search-forward
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
"\ew": copy-region-as-kill

I just moved to zsh, and would like to keep the same keyboard bindings I have in bash. Do the lines above have an equivalent in zsh?

Best Answer

Almost everything you can do in bash has a zsh equivalent, but you have to handle the translation on a case-by-case basis.

The line editor in zsh is zle. The command to bind keys is bindkey. The line edition commands that can be bound to keys are called widgets.

# You may want to call different history search commands, e.g.
# down-line-or-history or down-line-or-search (and up-*)
bindkey '^P' history-search-backward
bindkey '^N' history-search-forward
bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward
# The others should work already
Related Question