index.html :: rss :: github :: telegram :: email

zsh: better history search

14 Mar 2025

I absolutely love how zsh implemented the prefix search with an "arrow-up" key.

this feature is extremely useful for a long commands with lots of arguments, such as starting docker containers.

but! arrow keys are not so convenient to reach, especially when you touch-type-wannabe.

let's remap the ctrl+p, which is usually stands for "scroll history back", to do the same as "arrow-up" in zsh:

bindkey "^P" up-line-or-beginning-search
bindkey "^N" down-line-or-beginning-search

related stackoverflow post