2015-04-28 14:56:59 +08:00
|
|
|
This document is an unfinished draft.
|
|
|
|
|
2018-08-21 12:49:11 +08:00
|
|
|
# User Documentation
|
2015-04-28 14:56:59 +08:00
|
|
|
Table of contents:
|
2018-08-11 14:37:17 +08:00
|
|
|
|
2015-04-28 14:56:59 +08:00
|
|
|
* Installation
|
|
|
|
* Configuration
|
|
|
|
* Features
|
2018-08-21 12:49:11 +08:00
|
|
|
* History views
|
|
|
|
* Ranking
|
|
|
|
* Raw
|
|
|
|
* Favorites
|
|
|
|
* History filtering
|
|
|
|
* Choosing a command
|
|
|
|
* Favorite commands
|
|
|
|
* Blacklist
|
|
|
|
* Delete last command
|
2015-04-28 14:56:59 +08:00
|
|
|
* Examples
|
|
|
|
|
2018-08-21 12:49:11 +08:00
|
|
|
# Features
|
2019-12-17 05:34:15 +08:00
|
|
|
HSTR is typically started by pressing <kbd>Ctrl-r</kbd> after
|
2018-08-25 15:40:01 +08:00
|
|
|
you configure it for this shorcut in your shell. However,
|
2015-04-28 14:56:59 +08:00
|
|
|
you can run it as a normal program just by typing:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-08-25 15:40:01 +08:00
|
|
|
```bash
|
|
|
|
hstr
|
|
|
|
```
|
|
|
|
|
|
|
|
... or use simpler command configured using [alias](../CONFIGURATION.md#alias):
|
|
|
|
|
2015-04-28 14:56:59 +08:00
|
|
|
```bash
|
|
|
|
hh
|
|
|
|
```
|
|
|
|
|
|
|
|
It opens a page with a history view (ranking view is default).
|
2018-08-25 15:40:01 +08:00
|
|
|
Alternatively you can run HSTR in non-interactive mode -
|
2015-04-28 14:56:59 +08:00
|
|
|
commands are just listed on standard output based on history
|
|
|
|
view:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-04-28 14:56:59 +08:00
|
|
|
```bash
|
|
|
|
hh --non-interactive
|
|
|
|
```
|
|
|
|
|
|
|
|
Filtering pattern can be optionally specified as well:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-04-28 14:56:59 +08:00
|
|
|
```bash
|
|
|
|
hh -i git
|
|
|
|
```
|
|
|
|
|
|
|
|
Prints history items containing `git` to standard output and
|
|
|
|
exits.
|
|
|
|
|
2018-08-21 12:49:11 +08:00
|
|
|
## History Filtering
|
2018-08-12 02:14:46 +08:00
|
|
|
When HSTR starts in interative mode, a view of commands
|
2015-04-28 14:56:59 +08:00
|
|
|
is shown. This list of commands can be filtered just by typing
|
|
|
|
a string pattern.
|
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-08-21 12:49:11 +08:00
|
|
|
## Choosing a Command
|
2015-04-28 14:56:59 +08:00
|
|
|
When you filtered the view of history items enough, you can
|
|
|
|
move around it with `UP` and `DOWN` arrow keys. Selected history
|
|
|
|
items is highlighted. Once you are done with your choice:
|
|
|
|
|
|
|
|
* press `ENTER` to choose the command and execute it
|
2018-08-25 15:40:01 +08:00
|
|
|
* or press `TAB` or `RIGHT` arrow key to choose the command and edit it on command line after exiting HSTR
|
2019-12-17 05:40:43 +08:00
|
|
|
* or press `LEFT` arrow key to choose the command and open it in editor (`bash` `fc` i.e. fix command)
|
2015-04-28 14:56:59 +08:00
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-08-21 12:49:11 +08:00
|
|
|
## Favorite Commands
|
2018-08-12 02:14:46 +08:00
|
|
|
HSTR allows you to store and manage your favorite
|
2015-04-28 14:56:59 +08:00
|
|
|
commands.
|
|
|
|
|
|
|
|
A new favorite command can be added from
|
2019-12-17 05:34:15 +08:00
|
|
|
ranking or raw history view by pressing <kbd>Ctrl-f</kbd>.
|
2015-04-28 14:56:59 +08:00
|
|
|
|
|
|
|
You can check your favorite commands by choosing
|
2019-12-17 05:34:15 +08:00
|
|
|
favorite view - rotate views using <kbd>Ctrl-/</kbd> or start
|
2018-08-25 15:40:01 +08:00
|
|
|
HSTR by adding `favorites-view` to `HSTR_CONFIG` environment
|
2015-04-28 14:56:59 +08:00
|
|
|
property. A favorite command can be choosen just
|
|
|
|
by pressing `ENTER` when on command in favorite view.
|
|
|
|
Last chosen favorite commands appears as the first
|
|
|
|
one (at the top of the page) in the favorite view.
|
|
|
|
You can delete a favorite command with `DEL` key.
|
|
|
|
|
|
|
|
Tips:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-08-25 15:40:01 +08:00
|
|
|
* Favorite commands are stored in `~/.hstr_favorites`
|
2015-04-28 14:56:59 +08:00
|
|
|
* Suffix your favorite commands with comments
|
2018-08-13 21:42:09 +08:00
|
|
|
describing their purpose. For example:
|
|
|
|
|
|
|
|
```
|
|
|
|
printf "\e[?2004l" # fix terminal copy/paste
|
|
|
|
```
|
|
|
|
|
|
|
|
* Such comment can be used for normal commands
|
2015-04-28 14:56:59 +08:00
|
|
|
as well and may serve as a way how to **tag**
|
|
|
|
commands.
|
|
|
|
|
2018-08-13 21:42:09 +08:00
|
|
|
```bash
|
|
|
|
COMMAND # TAG1 TAG2 TAG3
|
|
|
|
...
|
|
|
|
printf "\e[?2004l" # fix broken copy/paste in terminal #TERM
|
|
|
|
```
|
2018-08-21 12:49:11 +08:00
|
|
|
## Blacklist
|
2018-08-12 02:14:46 +08:00
|
|
|
HSTR allows you to specify a set of commands to be
|
2015-04-28 14:56:59 +08:00
|
|
|
skipped from all the views. Blacklist typically contains
|
|
|
|
frequently used commands whose completion from history
|
|
|
|
has a little or no value. The default blacklist looks
|
|
|
|
like this:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
pwd
|
|
|
|
cd
|
|
|
|
cd ..
|
|
|
|
ls
|
2018-08-25 15:40:01 +08:00
|
|
|
hstr
|
2015-04-28 14:56:59 +08:00
|
|
|
mc
|
|
|
|
```
|
|
|
|
|
|
|
|
Tips:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-08-25 15:40:01 +08:00
|
|
|
* Blacklist of commands is stored in `~/.hstr_blacklist`
|
2015-04-28 14:56:59 +08:00
|
|
|
If the file doesn't exist, you may create it and complete
|
|
|
|
it with your own blacklist.
|
|
|
|
* You can skip any command from history just by
|
|
|
|
prefixing it with `SPACE`. For example:
|
2019-12-17 05:40:43 +08:00
|
|
|
` echo "Skip this from history"` It's a `bash`
|
2015-04-28 14:56:59 +08:00
|
|
|
option that is configured using
|
|
|
|
`HISTCONTROL=ignorespace` environment variable.
|
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-08-21 12:49:11 +08:00
|
|
|
## Kill the Last Command
|
2018-08-25 15:40:01 +08:00
|
|
|
Using HSTR you can easily delete the last command from history
|
2018-02-21 16:06:00 +08:00
|
|
|
e.g. when you make a typo or write something sensitive:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-02-21 16:06:00 +08:00
|
|
|
```
|
2018-08-25 15:40:01 +08:00
|
|
|
hstr --kill-last-command
|
2018-02-21 16:06:00 +08:00
|
|
|
```
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-02-21 16:06:00 +08:00
|
|
|
See configuration section for how to bind this functionality to
|
2019-12-17 05:34:15 +08:00
|
|
|
a key - bound to <kbd>Ctrl-k</kbd> by default.
|
2018-02-21 16:06:00 +08:00
|
|
|
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2018-08-21 12:49:11 +08:00
|
|
|
# Examples
|
2018-08-25 15:40:01 +08:00
|
|
|
Get more colors when running HSTR:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-04-28 14:56:59 +08:00
|
|
|
```bash
|
2018-08-25 15:40:01 +08:00
|
|
|
export HSTR_CONFIG=hicolor
|
2015-04-28 14:56:59 +08:00
|
|
|
```
|
|
|
|
|
2018-08-25 15:40:01 +08:00
|
|
|
Start HSTR in configured view and filter out history items
|
|
|
|
containing 'git' (make sure `hh` is defined using
|
|
|
|
[alias](../CONFIGURATION.md#alias)):
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-04-28 14:56:59 +08:00
|
|
|
```bash
|
|
|
|
hh git
|
|
|
|
```
|
|
|
|
|
|
|
|
Print history items containing 'git' to standard output and exit:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-04-28 14:56:59 +08:00
|
|
|
```bash
|
|
|
|
hh --non-interactive git
|
|
|
|
```
|
|
|
|
|
2019-12-17 05:40:43 +08:00
|
|
|
Append default `hh` configuration to your `bash` profile:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-04-28 14:56:59 +08:00
|
|
|
```bash
|
|
|
|
hh --show-configuration >> ~/.bashrc
|
|
|
|
```
|
|
|
|
|
2018-08-25 15:40:01 +08:00
|
|
|
Check HSTR man page:
|
2018-08-12 02:14:46 +08:00
|
|
|
|
2015-04-28 14:56:59 +08:00
|
|
|
```bash
|
2018-08-25 15:40:01 +08:00
|
|
|
man hstr
|
2015-04-28 14:56:59 +08:00
|
|
|
```
|