hh (1) - Linux Manuals

hh: easily view, navigate, sort and use your command history with shell history suggest box.

NAME

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

SYNOPSIS

hh [option] [arg1] [arg2]...
hstr [option] [arg1] [arg2]...

DESCRIPTION

hh 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 occurences, length and timestamp. Favorite and frequently used commands can be bookmarked. In addition hh allows removal of commands from history - for instance with a typo or with a sensitive content.

OPTIONS

-h --help
Show help
-n --non-interactive
Print filtered history on standard output and exit
-f --favorites
Show favorites view immediately
-s --show-configuration
Show configuration that can be added to ~/.bashrc
-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 occurences/length/timestamp and favorites.
Ctrl-f
Add currently selected command to favorites.
Ctrl-l
Make search pattern lowercase or uppercase.
Ctrl-r, UP arrow, DOWN arrow, Ctrl-n, Ctrl-p
Navigate in the history list.
TAB, RIGHT arrow
Choose currently selected item for completion and let user to edit it on the command prompt.
LEFT arrow
Choose currently selected item for completion and let user to 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.
BACSKSPACE, 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

hh defines the following environment variables:
HH_CONFIG
Configuration options:

hicolor
  Get more colors with this option (default is monochromatic).

monochromatic
  Ensure black and white view.

regexp
  Filter command history using regular expressions (substring match is default) 

substring
  Filter command history using substring.

keywords
  Filter command history using keywords - item matches if contains all keywords in pattern in any order.

casesensitive
  Make history filtering case sensitive (it's case insensitive by default). 

rawhistory
  Show normal history as a default view (metric-based view is shown otherwise). 

favorites
  Show favorites as a default view (metric-based view is shown otherwise).

blacklist
  Load list of commands to skip when processing history from ~/.hh_blacklist (built-in blacklist used otherwise).

bigkeysskip
  Skip big history entries i.e. very long lines (default).

bigkeysfloor
  Use different sorting slot for big keys when building metrics-based view (big keys are skipped by default).

bigkeysexit
  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 HH_CONFIG=hicolor,regexp,rawhistory

HH_PROMPT
Change prompt string which is user [at] host$ by default.

Example:
  export HH_PROMPT="$ "

FILES

~/.hh_favorites

 Bookmarked favorite commands.
~/.hh_blacklist

 Command blacklist.

BASH CONFIGURATION

Optionally add the following lines to ~/.bashrc:
export HH_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)
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
# if this is interactive shell, then bind hh to Ctrl-r (for Vi mode check doc)
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hh \C-j"'; fi
The prompt command ensures synchronization of the history between BASH memory and history file.

ZSH CONFIGURATION

Optionally add the following lines to ~/.zshrc:
export HISTFILE=~/.zsh_history   # ensure history file visibility
export HH_CONFIG=hicolor         # get more colors
bindkey -s "\C-r" "\eqhh\n"      # bind hh to Ctrl-r (for Vi mode check doc)

EXAMPLES

hh git

 Start `hh` and show only history items containing 'git'.
hh --non-interactive git

 Print history items containing 'git' to standard output and exit.
hh --show-configuration >> ~/.bashrc

 Append default hh configuration to your Bash profile.
hh --show-blacklist

 Show blacklist configured for history processing.

AUTHOR

Written by Martin Dvorak <martin.dvorak [at] mindforger.com>

BUGS

Report bugs to https://github.com/dvorka/hstr/issues

SEE ALSO

history(1), bash(1), zsh(1)