HSTR(1)
πΈ NAME πΈ β hstr from the General Commands Manual (HSTR(1)) π
hstr β easily view, navigate, sort and use your command history with a shell history suggest box. Thatβs the whole NAME vibe, bestie. π«Ά
β¨ SYNOPSIS β¨
hstr [option] [arg1] [arg2]...
π¦ DESCRIPTION π¦
hstr uses shell history to provide suggest box like functionality for commands used in the past. By default it parses the .bash-history file that is filtered as you type a command substring. Commands are not just filtered, but also ordered by a ranking algorithm that considers the number of occurrences, length and timestamp. Favorite and frequently used commands can be bookmarked. In addition hstr allows removal of commands from history β for instance with a typo or with sensitive content. No cap, itβs giving history glow-up. π
π OPTIONS π
-h,--helpβ show help π¬-n,--non-interactiveβ print filtered history on standard output and exit π€-k,--kill-last-commandβ delete the last command from history and exit π-i,--insert-in-terminal=[command]β insert custom command in terminal prompt and exit βοΈ-f,--favoritesβ show favorites view immediately β-s,--show-configurationβ show configuration to be added to the config file of the shell (~/.bashrcor~/.zshrc) π οΈ-B,--show-bash-configurationβ show Bash configuration to be added to~/.bashrcπ-Z,--show-zsh-configurationβ show Zsh configuration to be added to~/.zshrcπ-b,--show-blacklistβ show blacklist of commands to be filtered out before history processing π«-V,--versionβ show version information π·οΈ
π KEYS π
patternβ type to filter shell history. πCtrl-eβ toggle regular expression and substring search. πCtrl-tβ toggle case sensitive search. πCtrl-/,Ctrl-7β rotate view of history as provided by bash, ranked history ordered by the number of occurrences/length/timestamp and favorites. π‘Ctrl-fβ add currently selected command to favorites. πCtrl-lβ toggle search pattern case. πCtrl-r,UP arrow,DOWN arrow,Ctrl-n,Ctrl-p,Ctrl-j,Ctrl-kβ navigate in the history list. π§TAB,RIGHT arrowβ choose currently selected item for completion and let user edit it on the command prompt. β‘οΈLEFT arrowβ choose currently selected item for completion and let user edit it in editor (fix command). β¬ οΈENTERβ choose currently selected item for completion and execute it. πDELβ remove currently selected item from the shell history. ποΈBACKSPACE,Ctrl-hβ delete last pattern character. β«Ctrl-u,Ctrl-wβ delete pattern and search again. π§ΉCtrl-xβ write changes to shell history and exit. πΎCtrl-gβ exit with empty prompt. π
π ENVIRONMENT VARIABLES π
hstr defines the following environment variables:
π HSTR_CONFIG π
Configuration options:
hicolorβ get more colors with this option (default is monochromatic). π¨monochromaticβ ensure black and white view. π€prompt-bottomβ show prompt at the bottom of the screen (default is prompt at the top). β¬οΈhelp-on-opposite-sideβ show help label on the opposite side (default is next to the prompt). βοΈhide-basic-helpβ hide the basic help label. πhide-helpβ hide basic and history help labels. Implicitly setshide-basic-help. πno-confirmβ do not ask for confirmation on a history entry delete (default is with confirmation). βregexp-matchingβ filter command history using regular expressions. π§ͺsubstring-matchingβ filter command history using substring. π§΅keywords-matchingβ filter command history using keywords β item matches if contains all keywords in pattern in any order (keywords match is default). πcase-sensitiveβ make history filtering case sensitive (itβs case insensitive by default). π‘raw-history-viewβ show normal history as a default view (metric-based view is shown otherwise). πfavorites-viewβ show favorites as a default view (metric-based view is shown otherwise). π«static-favoritesβ do not put recently used favorite to the head of favorites (favorites are reordered by default). πskip-favorites-commentsβ skip comments (lines beginning with#) when loading~/.hstr_favorites(all lines are loaded by default). π¬duplicatesβ show duplicates in raw history (duplicates are discarded by default). π―verbose-killβ print the last command deleted from history (nothing is printed by default). π£blacklistβ load list of commands to skip when processing history from~/.hstr_blacklist(built-in blacklist used otherwise). π«keep-pageβ donβt clear page with command selection on exit (page is cleared by default). πbig-keys-skipβ skip big history entries i.e. very long lines (default). π¦£big-keys-floorβ use different sorting slot for big keys when building metrics-based view (big keys are skipped by default). ποΈbig-keys-exitβ exit (fail) on presence of a big key in history (big keys are skipped by default). π₯warningβ show warning. β οΈdebugβ show debug information. π
Example:
export HSTR_CONFIG=hicolor,regexp-matching,raw-history-view
π HSTR_PROMPT π
Change prompt string which is user@host$ by default.
Example:
export HSTR_PROMPT="$ "
πΈ FILES πΈ
~/.hstr_favoritesβ bookmarked favorite commands. β~/.hstr_blacklistβ commands to be hidden. π
π BASH CONFIGURATION π
Add the following lines to ~/bashrc if TIOCSTI is not supported by your OS:
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}"
function hstrnotiocsti {
{ READLINE_LINE=
READLINE_POINT=${#READLINE_LINE}
}
# if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
if [[ $- =~ .*i.* ]]; then bind -x '""hstrnotiocsti"'; fi
export HSTR_TIOCSTI=n
Optionally add the following lines to ~/.bashrc if TIOCSTI is supported by your OS:
alias hh=hstr # make hh alias of 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
π ZSH CONFIGURATION π
Add the following lines to ~/zshrc if TIOCSTI is not supported by your OS:
alias hh=hstr # hh to be alias for hstr
setopt histignorespace # skip cmds w/ leading space from history
export HSTR_CONFIG=hicolor # get more colors
hstr_no_tiocsti() {
zle -I
{ HSTR_OUT="$( { </dev/tty hstr -- ${BUFFER}; } 2>&1 1>&3 3>&- )"; } 3>&1;
BUFFER="${HSTR_OUT}"
CURSOR=${#BUFFER}
zle redisplay
}
zle -N hstr_no_tiocsti
bindkey 'hstr_no_tiocsti
export HSTR_TIOCSTI=n
Optionally add the following lines to ~/.zshrc if TIOCSTI is supported by your OS:
export HSTR_CONFIG=hicolor # get more colors
setopt histignorespace # skip cmds w/ leading space from history
bindkey -s "\C-r" "\C-a hstr -- \C-j" # bind hstr to Ctrl-r (for Vi mode check doc)
π EXAMPLES π
hstr gitβ starthstrand show only history items containing'git'. πhstr cpp add gitβ starthstrand show only history items containing'cpp','add'and'git'. πhstr --non-interactive gitβ print history items containing'git'to standard output and exit. π€hstr --show-configuration >> ~/.bashrcβ append defaulthstrconfiguration to your Bash profile. πhstr --show-configuration >> ~/.zhrcβ append defaulthstrconfiguration to your Zsh profile. πhstr --show-blacklistβ show blacklist configured for history processing. π«hstr --insert-in-terminal="git add . && git diff --cached"β insert command in terminal prompt and exit. βοΈ
π AUTHOR π
Written by Martin Dvorak <martin.dvorak@mindforger.com> π
π BUGS π
Report bugs to https://github.com/dvorka/hstr/issues π
π§ SEE ALSO π§
history(1), bash(1), zsh(1) π«Ά
π okay bestie, thatβs the whole HSTR(1) page. The footer just says HSTR(1) β no extra source/version/date tea in this copy, so thatβs all she wrote, periodt. πβ¨
π¦ where this page comes from
- alpine 3.24: hstr-doc 3.2-r0 Β· Apache-2.0
- nixpkgs unstable: hstr 3.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms