2018-08-12 02:14:46 +08:00
|
|
|
# Configuration
|
2015-02-13 16:19:36 +08:00
|
|
|
Get most of HSTR by configuring it with:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
hh --show-configuration >> ~/.bashrc
|
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
|
|
|
Run `hh --show-configuration` to determine what will be appended to your Bash profile. Don't forget
|
|
|
|
to source `~/.bashrc` to apply changes.
|
|
|
|
|
|
|
|
---
|
2015-01-08 05:36:50 +08:00
|
|
|
|
2015-03-01 01:00:20 +08:00
|
|
|
For more configuration options details please refer to:
|
2018-08-11 14:37:17 +08:00
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
* Bind `hh` to a [keyboard shortcut](#binding-hh-to-keyboard-shortcut)
|
|
|
|
* Get more [colors](#colors)
|
|
|
|
* Choose [default history view](#history-view)
|
|
|
|
* Set [filtering preferences](#filtering)
|
|
|
|
* Configure commands [blacklist](#blacklist)
|
|
|
|
* Disable [confirm on delete](#confirm-on-delete)
|
|
|
|
* Tune [verbosity](#verbosity)
|
|
|
|
* Bash:
|
|
|
|
* [Bash Emacs keymap](#bash-emacs-keymap-default) (default)
|
|
|
|
* [Bash Vim keymap](#bash-vim-keymap-default)
|
|
|
|
* [Bash history settings](#bash-history-settings)
|
|
|
|
* zsh:
|
|
|
|
* [zsh Emacs keymap](#zsh-emacs-keymap-default) (default)
|
|
|
|
* [zsh history settings](#zsh-history-settings)
|
2015-03-01 01:00:20 +08:00
|
|
|
|
|
|
|
Check also configuration [examples](#examples).
|
2015-01-08 06:23:49 +08:00
|
|
|
|
2018-08-22 15:31:23 +08:00
|
|
|
## Alias
|
|
|
|
Make running of `hstr` (e.g. if you don't want to bind it to <kbd>Ctrl+r</kbd>)
|
|
|
|
even easier by defining alias in your `~/.bashrc`:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
alias hh=hstr
|
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
## Binding HSTR to Keyboard Shortcut
|
2015-02-13 16:19:36 +08:00
|
|
|
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:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-02-13 16:19:36 +08:00
|
|
|
```bash
|
|
|
|
bind -v | grep editing-mode
|
|
|
|
bind -v | grep keymap
|
|
|
|
```
|
|
|
|
|
|
|
|
To determine character sequence emitted by a pressed key in
|
2018-08-12 02:14:46 +08:00
|
|
|
terminal, type <kbd>Ctrl</kbd><kbd>v</kbd> and then press the key. Check your
|
2015-02-13 16:19:36 +08:00
|
|
|
current bindings using:
|
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
2018-08-12 02:14:46 +08:00
|
|
|
bind -S
|
2015-01-08 05:36:50 +08:00
|
|
|
```
|
|
|
|
|
2015-02-13 16:19:36 +08:00
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
## Colors
|
2015-01-08 05:36:50 +08:00
|
|
|
Get `hh` in more colors:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=hicolor
|
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 06:44:07 +08:00
|
|
|
or ensure black and white mode:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 06:23:49 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=monochromatic
|
|
|
|
```
|
|
|
|
|
2018-08-22 15:57:28 +08:00
|
|
|
## Default History View
|
2015-01-08 06:23:49 +08:00
|
|
|
Show normal history by default (instead of metrics-based view):
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
2018-08-22 15:50:44 +08:00
|
|
|
export HH_CONFIG=raw-history-view
|
2015-01-08 05:36:50 +08:00
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 06:44:07 +08:00
|
|
|
Show favorite commands by default (instead of metrics-based view):
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
2018-08-22 15:50:44 +08:00
|
|
|
export HH_CONFIG=favorites-view
|
2015-01-08 05:36:50 +08:00
|
|
|
```
|
2015-01-08 06:23:49 +08:00
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
## Filtering
|
2018-08-22 15:57:28 +08:00
|
|
|
To use regular expressions based matching:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
export HH_CONFIG=regexp-matching
|
|
|
|
```
|
|
|
|
|
|
|
|
To use substring based matching:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
export HH_CONFIG=substring-matching
|
|
|
|
```
|
|
|
|
|
|
|
|
To use keywords (substrings whose order doesn't matter) search matching (default):
|
|
|
|
|
|
|
|
```bash
|
|
|
|
export HH_CONFIG=keywords-matching
|
|
|
|
```
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2015-01-08 06:44:07 +08:00
|
|
|
Make search case sensitive (insensitive by default):
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
2018-08-22 15:57:28 +08:00
|
|
|
export HH_CONFIG=case-sensitive
|
2015-01-08 05:36:50 +08:00
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-08-22 15:57:28 +08:00
|
|
|
Keep duplicates in `raw-history-view` (duplicate commands are discarded by default):
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-12-30 06:21:40 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=duplicates
|
|
|
|
```
|
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
## Static favorites
|
2018-08-22 15:50:44 +08:00
|
|
|
Last selected favorite command is put the head of favorite commands list
|
2018-08-12 02:14:46 +08:00
|
|
|
by default. If you want to disable this behavior and make favorite
|
|
|
|
commands list static, then use the following configuration:
|
|
|
|
|
|
|
|
```bash
|
2018-08-22 15:44:19 +08:00
|
|
|
export HH_CONFIG=static-favorites
|
2018-08-12 02:14:46 +08:00
|
|
|
```
|
2018-08-22 15:50:44 +08:00
|
|
|
## Skip favorites comments
|
|
|
|
If you don't want to show lines starting with `#` (comments) among
|
|
|
|
favorites, then use the following configuration:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
export HH_CONFIG=skip-favorites-comments
|
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
## Blacklist
|
2015-05-28 13:08:15 +08:00
|
|
|
Skip commands when processing history i.e. make sure that these commands
|
|
|
|
will *not* be shown in any view:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-05-28 13:08:15 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=blacklist
|
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-05-28 13:08:15 +08:00
|
|
|
Commands to be stored in `~/.hh_blacklist` file with trailing empty line. For instance:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-05-28 13:08:15 +08:00
|
|
|
```
|
|
|
|
cd
|
|
|
|
my-private-command
|
|
|
|
ls
|
|
|
|
ll
|
|
|
|
```
|
2018-08-11 14:48:25 +08:00
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
## Confirm on Delete
|
2018-02-08 20:10:45 +08:00
|
|
|
Do not prompt for confirmation when deleting history items:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-02-08 20:10:45 +08:00
|
|
|
```bash
|
2018-08-22 16:00:14 +08:00
|
|
|
export HH_CONFIG=no-confirm
|
2018-02-08 20:10:45 +08:00
|
|
|
```
|
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
## Verbosity
|
2018-02-21 16:06:00 +08:00
|
|
|
Show a message when deleting the last command from history:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-02-21 16:06:00 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=verbose-kill
|
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 06:44:07 +08:00
|
|
|
Show warnings:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=warning
|
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 06:44:07 +08:00
|
|
|
Show debug messages:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=debug
|
|
|
|
```
|
2015-01-08 06:23:49 +08:00
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
## Bash Emacs Keymap (default)
|
|
|
|
Bind `hh` to a Bash key e.g. to <kbd>Ctrl</kbd><kbd>r</kbd>:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
bind '"\C-r": "\C-ahh -- \C-j"'
|
|
|
|
```
|
|
|
|
|
|
|
|
or <kbd>Ctrl</kbd><kbd>Alt</kbd><kbd>r</kbd>:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
bind '"\e\C-r":"\C-ahh -- \C-j"'
|
|
|
|
```
|
|
|
|
|
|
|
|
or <kbd>Ctrl</kbd><kbd>F12</kbd>:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
bind '"\e[24;5~":"\C-ahh -- \C-j"'
|
|
|
|
```
|
|
|
|
|
|
|
|
Bind `hh` to <kbd>Ctrl</kbd><kbd>r</kbd> only if it is interactive shell:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hh -- \C-j"'; fi
|
|
|
|
```
|
|
|
|
|
|
|
|
You can bind also other `hh` commands like `-kill-last-command`:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
if [[ $- =~ .*i.* ]]; then bind '"\C-xk": "\C-a hh -k \C-j"'; fi
|
|
|
|
```
|
|
|
|
|
|
|
|
## Bash Vim Keymap
|
|
|
|
Bind `hh` to a Bash key e.g. to <kbd>Ctrl</kbd><kbd>r</kbd>:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
bind '"\C-r": "\e0ihh -- \C-j"'
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Bash History Settings
|
2015-01-08 06:23:49 +08:00
|
|
|
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):
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HISTFILESIZE=10000
|
|
|
|
export HISTSIZE=${HISTFILESIZE}
|
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
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:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```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):
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
shopt -s histappend
|
|
|
|
```
|
|
|
|
|
|
|
|
Use leading space to hide commands from history:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
```bash
|
|
|
|
export HISTCONTROL=ignorespace
|
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-01-08 05:36:50 +08:00
|
|
|
Suitable for a sensitive information like passwords.
|
2015-01-13 22:57:31 +08:00
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
## Zsh Emacs Keymap (default)
|
|
|
|
Bind `hh` to a `zsh` key e.g. to <kbd>Ctrl</kbd><kbd>r</kbd>:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
bindkey -s "\C-r" "\eqhh --\n"
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Zsh History Settings
|
|
|
|
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
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
|
|
|
|
## Examples
|
2015-03-01 01:00:20 +08:00
|
|
|
More colors with case sensitive search of history:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-03-01 01:00:20 +08:00
|
|
|
```bash
|
2018-08-22 16:00:14 +08:00
|
|
|
export HH_CONFIG=hicolor,case-sensitive
|
2015-03-01 01:00:20 +08:00
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-03-01 01:00:20 +08:00
|
|
|
Favorite commands view in black and white:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-03-01 01:00:20 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=favorites,monochromatic
|
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-03-01 01:00:20 +08:00
|
|
|
Keywords based search in colors with debug mode verbosity:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-03-01 01:00:20 +08:00
|
|
|
```bash
|
|
|
|
export HH_CONFIG=keywords,hicolor,debug
|
|
|
|
```
|