hh(1)
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,UParrow,DOWNarrow,Ctrl-n,Ctrl-p- Navigate in the history list.
TAB,RIGHTarrow- Choose currently selected item for completion and let user to edit it on the command prompt.
LEFTarrow- 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:
HH_PROMPT- Change prompt string which is
user [at] host$by default.
hicolor
monochromatic
regexp
substring
keywords
casesensitive
rawhistory
favorites
blacklist
bigkeysskip
bigkeysfloor
bigkeysexit
warning
debug
Example:
export HH_CONFIG=hicolor,regexp,rawhistory
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" "qhh " # 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 hhconfiguration 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