HSTR(1) | General Commands Manual | HSTR(1) |
hstr - easily view, navigate, sort and use your command history with shell history suggest box.
hstr [option] [arg1] [arg2]...
hstr uses shell history to provide suggest box like functionality for commands used in the past. By default it parses .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 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 a sensitive content.
hstr defines the following environment variables:
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 site (default is next to the prompt).
hide-basic-help
Hide the basic help label.
hide-help
Hide basic and history help labels. Implicitly sets hide-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 rawhistory (duplicates are discarded by default).
verbose-kill
Print the last command 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
Example:
export HSTR_PROMPT="$ "
Optionally add the following lines to ~/.bashrc:
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
Optionally add the following lines to ~/.zshrc:
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)
Written by Martin Dvorak <martin.dvorak@mindforger.com>
Report bugs to https://github.com/dvorka/hstr/issues