Scroll to navigation

HSTR(1) General Commands Manual HSTR(1)

NAME

hstr - easily view, navigate, sort and use your command history with shell history suggest box.

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 .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.

OPTIONS

Show help
Print filtered history on standard output and exit
Delete the last command from history and exit
Insert custom command to terminal prompt and exit
Show favorites view immediately
Show configuration that can be added to ~/.bashrc
Show blacklist of commands to be filtered out before history processing
Show version information

KEYS

Type to filter shell history.
Toggle regular expression and substring search.
Toggle case sensitive search.
Rotate view of history as provided by bash, ranked history ordered by the number of occurences/length/timestamp and favorites.
Add currently selected command to favorites.
Toggle search pattern case.
Navigate in the history list.
Choose currently selected item for completion and let user to edit it on the command prompt.
Choose currently selected item for completion and let user to edit it in editor (fix command).
Choose currently selected item for completion and execute it.
Remove currently selected item from the shell history.
Delete last pattern character.
Delete pattern and search again.
Write changes to shell history and exit.
Exit with empty prompt.

ENVIRONMENT VARIABLES

hstr defines the following environment variables:

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 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

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

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

ZSH CONFIGURATION

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)

EXAMPLES


Start hstr and show only history items containing 'git'.

Start hstr and show only history items containing 'cpp', 'add' and 'git'.

Print history items containing 'git' to standard output and exit.

Append default hstr configuration to your bash profile.

Append default hstr configuration to your zsh profile.

Show blacklist configured for history processing.

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)