Skip to content

Instantly share code, notes, and snippets.

@bluebrown
Created February 19, 2020 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluebrown/6ad5d0e39d25a71453cccece7b62ef03 to your computer and use it in GitHub Desktop.
Save bluebrown/6ad5d0e39d25a71453cccece7b62ef03 to your computer and use it in GitHub Desktop.
zsh smart-history

Add the following lines to the zsh config e.g. .zshrc

bindkey '\e[A' history-beginning-search-backward
bindkey '\e[B' history-beginning-search-forward

The behavior of history-beginning-search-backward is as follows:

Search forward in the history for a line beginning with the current line up to the cursor. This leaves the cursor in its original position.

Also, if \e[A doesn't work for the up or down arrows, press <ctrl-v><KEY (e.g., up arrow)> in another terminal which gives ^[OA. Then you can use this instead of \e[A. The process is described here: http://zshwiki.org/home/zle/bindkeys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment