Skip to content

Instantly share code, notes, and snippets.

@revgum
Created December 10, 2020 16:20
Show Gist options
  • Save revgum/13573ea565e9922dd96d362ef99ee7b8 to your computer and use it in GitHub Desktop.
Save revgum/13573ea565e9922dd96d362ef99ee7b8 to your computer and use it in GitHub Desktop.
ohmyzsh history substring search

With ohmyzsh installed, and two plugins history and history-substring-search enabled, the following key binding provides the means for search for commands you've previously typed.

You can type a part of the command you're looking to use then press the up-arrow or down-arrow key on the keyboard repeatedly to search through your history for the command you need.

First make sure ~/.zshrc includes;

plugins=(
    history
    history-substring-search
    ...ANY OTHER PLUGINS YOU USE...
)
# Bind the up-arrow key to do a history substring search 
bindkey '^[[A' history-substring-search-up
# Bind the down-arrow key to do a history substring search
bindkey '^[[B] history-substring-search-down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment