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 (~/.bashrc or ~/.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 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 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 β€” start hstr and show only history items containing 'git'. πŸ”Ž
  • hstr cpp add git β€” start hstr and 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 default hstr configuration to your Bash profile. 🐚
  • hstr --show-configuration >> ~/.zhrc β€” append default hstr configuration 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