2015-01-08 06:23:49 +08:00
|
|
|
CONFIGURATION
|
|
|
|
=============
|
2015-02-13 16:19:36 +08:00
|
|
|
Get most of HSTR by configuring it with:
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
hh --show-configuration >> ~/.bashrc
|
|
|
|
```
|
2015-02-13 16:19:36 +08:00
|
|
|
Run `hh --show-configuration` to determine what will be appended to your Bash profile.
|
2015-01-08 05:36:50 +08:00
|
|
|
|
2015-03-01 01:00:20 +08:00
|
|
|
For more configuration options details please refer to:
|
|
|
|
* bind `hh` command to a [keyboard shortcut](#binding-hh-to-keyboard-shortcut)
|
|
|
|
* get more [colors](#colors)
|
|
|
|
* choose [default history view](#history-view)
|
|
|
|
* [verbosity](#verbosity)
|
|
|
|
* [Bash history settings](#bash-history-settings)
|
|
|
|
* [zsh history settings](#zsh-history-settings)
|
|
|
|
|
|
|
|
Check also configuration [examples](#examples).
|
2015-01-08 06:23:49 +08:00
|
|
|
|
|
|
|
|
2015-02-13 16:19:36 +08:00
|
|
|
BINDING HSTR TO KEYBOARD SHORTCUT
|
|
|
|
---------------------------------
|
|
|
|
Bash uses *Emacs* style keyboard shortcuts by default. There is
|
|
|
|
also *Vi* mode. Find out how to bind HSTR to a keyboard shortcut
|
|
|
|
based on the style you prefer below.
|
|
|
|
|
|
|
|
Check your active Bash keymap with:
|
|
|
|
```bash
|
|
|
|
bind -v | grep editing-mode
|
|
|
|
bind -v | grep keymap
|
|
|
|
```
|
|
|
|
|
|
|
|
To determine character sequence emitted by a pressed key in
|
|
|
|
terminal, type `Ctrl-v` and then press the key. Check your
|
|
|
|
current bindings using:
|
|
|
|
```bash
|
|
|
|
bind -S
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## BASH EMACS KEYMAP (DEFAULT)
|
|
|
|
Bind `hh` to a Bash key e.g. to `Ctrl-r`:
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
bind '"\C-r": "\C-ahh \C-j"'
|
|
|
|
```
|
|
|
|
or `Ctrl-Alt-r`:
|
|
|
|
```bash
|
|
|
|
bind '"\e\C-r":"\C-ahh \C-j"'
|
|
|
|
```
|
|
|
|
or `Ctrl-F12`:
|
|
|
|
```bash
|
|
|
|
bind '"\e[24;5~":"\C-ahh \C-j"'
|
|
|
|
```
|
2015-01-08 06:44:07 +08:00
|
|
|
Bind `hh` to `Ctrl-r` only if it is interactive shell:
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hh \C-j"'; fi
|
|
|
|
```
|
|
|
|
|
2015-02-13 16:19:36 +08:00
|
|
|
## BASH VI KEYMAP
|
|
|
|
Bind `hh` to a Bash key e.g. to `Ctrl-r`:
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
2015-02-13 16:19:36 +08:00
|
|
|
bind '"\C-r": "\C-ahh \C-j"'
|
2015-01-08 05:36:50 +08:00
|
|
|
```
|
|
|
|
|
2015-02-13 16:22:30 +08:00
|
|
|
## ZSH EMACS KEYMAP (DEFAULT)
|
2015-02-13 16:19:36 +08:00
|
|
|
Bind `hh` to a Zsh key e.g. to `Ctrl-r`:
|
|
|
|
```bash
|
|
|
|
bindkey -s "\C-r" "\eqhh\n"
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2015-01-08 06:23:49 +08:00
|
|
|
COLORS
|
|
|
|
------
|
2015-01-08 05:36:50 +08:00
|
|
|
Get `hh` in more colors:
|
|
|
|
```bash
|
|
|
|
export HH_CONFIG=hicolor
|
|
|
|
```
|
2015-01-08 06:44:07 +08:00
|
|
|
or ensure black and white mode:
|
2015-01-08 06:23:49 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=monochromatic
|
|
|
|
```
|
|
|
|
|
2015-03-01 01:00:20 +08:00
|
|
|
|
2015-01-08 06:23:49 +08:00
|
|
|
HISTORY VIEW
|
|
|
|
------------
|
|
|
|
Show normal history by default (instead of metrics-based view):
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=rawhistory
|
|
|
|
```
|
2015-01-08 06:44:07 +08:00
|
|
|
Show favorite commands by default (instead of metrics-based view):
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=favorites
|
|
|
|
```
|
2015-01-08 06:23:49 +08:00
|
|
|
|
2015-03-01 01:00:20 +08:00
|
|
|
|
2015-01-08 06:23:49 +08:00
|
|
|
FILTERING
|
|
|
|
---------
|
2015-01-08 06:44:07 +08:00
|
|
|
Make search case sensitive (insensitive by default):
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=casesensitive
|
|
|
|
```
|
2015-01-08 06:23:49 +08:00
|
|
|
|
2015-01-08 06:44:07 +08:00
|
|
|
VERBOSITY
|
2015-01-08 06:23:49 +08:00
|
|
|
-------
|
2015-01-08 06:44:07 +08:00
|
|
|
Show warnings:
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=warning
|
|
|
|
```
|
2015-01-08 06:44:07 +08:00
|
|
|
Show debug messages:
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=debug
|
|
|
|
```
|
2015-01-08 06:23:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
BASH HISTORY SETTINGS
|
|
|
|
---------------------
|
|
|
|
Use the following BASH settings to get most out of `hh`.
|
2015-01-08 05:36:50 +08:00
|
|
|
|
2015-01-13 22:57:31 +08:00
|
|
|
Increase the size of history maintained by BASH - variables defined below increase the
|
2015-01-08 06:44:07 +08:00
|
|
|
number of history items and history file size (default value is 500):
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HISTFILESIZE=10000
|
|
|
|
export HISTSIZE=${HISTFILESIZE}
|
|
|
|
```
|
2015-01-13 22:57:31 +08:00
|
|
|
Ensure syncing (flushing and reloading) of `.bash_history` with in-memory
|
2015-01-08 05:36:50 +08:00
|
|
|
history:
|
|
|
|
```bash
|
|
|
|
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
|
|
|
|
```
|
|
|
|
|
2015-01-13 22:57:31 +08:00
|
|
|
Force appending of in-memory history to `.bash_history`
|
|
|
|
(instead of overwriting):
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
shopt -s histappend
|
|
|
|
```
|
|
|
|
|
|
|
|
Use leading space to hide commands from history:
|
|
|
|
```bash
|
|
|
|
export HISTCONTROL=ignorespace
|
|
|
|
```
|
|
|
|
Suitable for a sensitive information like passwords.
|
2015-01-13 22:57:31 +08:00
|
|
|
|
|
|
|
ZSH HISTORY SETTINGS
|
|
|
|
--------------------
|
2015-01-14 05:59:12 +08:00
|
|
|
If you use `zsh`, set HISTFILE environment variable in ~/.zshrc:
|
2015-01-13 22:57:31 +08:00
|
|
|
|
|
|
|
```
|
|
|
|
export HISTFILE=~/.zsh_history
|
|
|
|
```
|
2015-03-01 01:00:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES
|
|
|
|
--------
|
|
|
|
More colors with case sensitive search of history:
|
|
|
|
```bash
|
|
|
|
export HH_CONFIG=hicolor,casesensitive
|
|
|
|
```
|
|
|
|
Favorite commands view in black and white:
|
|
|
|
```bash
|
|
|
|
export HH_CONFIG=favorites,monochromatic
|
|
|
|
```
|
|
|
|
Keywords based search in colors with debug mode verbosity:
|
|
|
|
```bash
|
|
|
|
export HH_CONFIG=keywords,hicolor,debug
|
|
|
|
```
|