HSTR makes it easy to search Bash or Zsh command history

High speed steel It is an ncurses-based tool for Bash and Zsh that can easily view, navigate, and search command history.
The interactive command line utility is designed to make Ctrl + r, And also allows you to delete entries from the command history and bookmark commands for easy access. When called, HSTR displays a list of the most recently used commands in order. You can use the following command to change the view to show chronological order history or favorites Ctrl + /. To use Up / Down Press the key to browse the command history, or start typing to find the desired command.

HSTR supports 3 types of filtering, you can switch among them Ctrl + e: Keyword search (substrings that do not matter in order), this is the default setting, based on substring matching and regular expression matching. By default, the search is not case sensitive, but can be changed using Ctrl + t.
Once you find the command you need, use Enter Run it or press TAB Complete it (and exit HSTR). You can use the following commands to add commands to favorites Ctrl + f, Or use the following commands to delete commands (for example, commands that may contain sensitive data) DELRelated: Bookmark terminal commands and easily retrieve them using tags
The default history view, filtering and case-sensitive / case-insensitive settings can all be permanently changed by exporting the corresponding variables in your computer ~/.bashrc Or ~/.zsh File-you can find various configuration options Here.
You can watch the HSTR demo in the following animated GIF (picture source: HSTR GitHub):HSTR makes it easy to search Bash or Zsh command history

Install HSTR

To install HSTR, see installation section. You will find packages for various Linux distributions, from Ubuntu, Fedora and openSUSE to Arch Linux, Genoo or CentOS. The macOS software package is also available.
After the installation is complete, run the following command (only once, because it does not check whether the HSTR configuration has been added) to attach its configuration to your ~/.bashrc Archive and source:

hstr --show-configuration >> ~/.bashrc
. ~/.bashrc

I am not sure if this command is also compatible with Zsh which I do not use. If using Zsh, you may need Configuration Perform hstr manually.
This is what the hstr “–show-configuration” command added to my ~/.bashrc file:

# HSTR configuration - add this to ~/.bashrc
alias hh=hstr                    # hh to be alias for hstr
export HSTR_CONFIG=hicolor       # get more colors
shopt -s histappend              # append new history items to .bash_history
export HISTCONTROL=ignorespace   # leading space hides commands from history
export HISTFILESIZE=10000        # increase history file size (default is 500)
export HISTSIZE=${HISTFILESIZE}  # increase history size (default is 500)
# ensure synchronization between Bash memory and history file
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
# if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
if [[ $- =~ .*i.* ]]; then bind '"C-r": "C-a hstr -- C-j"'; fi
# if this is interactive shell, then bind 'kill last command' to Ctrl-x k
if [[ $- =~ .*i.* ]]; then bind '"C-xk": "C-a hstr -k C-j"'; fi

If you delete HSTR, please remember from ~/.bashrc file. Now you can use call HSTR Ctrl + r At the terminal.
To customize HSTR, including changing its default history view, keyboard shortcuts, blacklist commands (hide them from any HSTR view), etc., please visit it configuration page.