hstr/README.md

189 lines
3.9 KiB
Markdown
Raw Normal View History

2013-12-03 06:47:51 +08:00
hstr
====
2014-01-24 15:31:55 +08:00
BASH History Suggest Box - [http://www.youtube.com/watch?v=sPF29NyXe2U](http://www.youtube.com/watch?v=sPF29NyXe2U)
2014-01-20 04:54:14 +08:00
2013-12-03 06:55:33 +08:00
DESCRIPTION
-----------
A command line utility that brings improved BASH command completion
2014-01-27 02:18:21 +08:00
from the history. It aims to make completion easier and more efficient
2014-01-27 02:17:42 +08:00
than `Ctrl-r`.
2013-12-03 06:55:33 +08:00
2014-01-28 16:11:17 +08:00
[![BASH History Suggest Box](http://mindforger.com/projects/images/hh-2.jpg "BASH History Suggest Box")](http://mindforger.com/projects/images/hh-2.jpg)
2013-12-16 15:15:11 +08:00
UBUNTU INSTALLATION
-------------------
2014-04-06 15:32:31 +08:00
* install `hh` on Ubuntu (12.04LTS/12.10/13.10/14.04LTS):
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
sudo add-apt-repository ppa:ultradvorka/ppa
sudo apt-get update
sudo apt-get install hh
```
2013-12-26 08:17:46 +08:00
2014-01-27 01:14:47 +08:00
* optionally configure `hh`:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
hh --show-configuration >> ~/.bashrc
```
2014-01-10 08:21:21 +08:00
2014-02-19 06:11:38 +08:00
DEBIAN/MINT INSTALLATION
-------------------
* install `hh` on Debian (Wheezy) or Mint (13) by registering the key:
```bash
wget www.clfh.de/frankh.asc
apt-key add frankh.asc
```
adding the repository:
```bash
deb http://www.clfh.de/debian wheezy main
deb-src http://www.clfh.de/debian wheezy main
```
and installing it:
```bash
apt-get update
apt-get install hh
```
* optionally configure `hh`:
```bash
hh --show-configuration >> ~/.bashrc
2014-02-19 06:12:29 +08:00
```
2014-02-19 06:11:38 +08:00
2014-03-02 14:30:31 +08:00
ARCH LINUX
----------
* download latest distribution from project Releases section:
2014-01-10 08:30:53 +08:00
https://github.com/dvorka/hstr/releases
2014-03-02 14:30:31 +08:00
* use PKGBUILD in the root of the distribution to build package using `makepkg`:
2014-01-10 08:30:53 +08:00
2014-03-02 14:30:31 +08:00
https://wiki.archlinux.org/index.php/PKGBUILD
2014-01-10 08:21:21 +08:00
2014-03-02 14:30:31 +08:00
* install `hh`
2014-01-27 01:14:47 +08:00
* optionally configure `hh`:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
hh --show-configuration >> ~/.bashrc
```
2014-01-10 08:21:21 +08:00
MAC OS
------
2014-01-17 11:46:12 +08:00
* install MacPorts:
http://www.macports.org
2014-01-27 01:14:47 +08:00
* set the environment:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
env CFLAGS="-I/opt/local/include -I/usr/include" LDFLAGS="-L/opt/local/lib -L/usr/lib" ./configure
```
* finish the installation
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
make && make install
```
2014-01-27 01:14:47 +08:00
* optionally configure `hh`:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
hh --show-configuration >> ~/.bashrc
```
2014-03-02 14:30:31 +08:00
INSTALLATION FROM SOURCE CODE
-----------------------------
* download latest distribution from project Releases section:
https://github.com/dvorka/hstr/releases
* expand the archive and install `hh` using:
```bash
./configure && make && make install
```
* optionally configure `hh`:
```bash
hh --show-configuration >> ~/.bashrc
```
CONFIGURATION EXPLANATION
-------------------------
2014-01-27 01:31:32 +08:00
* `hh` works best with the optional configuration described in this section.
You can configure `hh` just by running:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:31:32 +08:00
hh --show-configuration >> ~/.bashrc
```
* bind `hh` to a BASH key e.g. to `Ctrl-r`:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
bind '"\C-r": "\C-ahh \C-j"'
```
2014-02-19 05:49:48 +08:00
or `Ctrl-Alt-r`:
```bash
bind '"\e\C-r":"\C-ahh \C-j"'
```
2014-01-27 01:31:32 +08:00
or `Ctrl-F12`:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
bind '"\e[24;5~":"\C-ahh \C-j"'
```
bind `hh` to `Ctrl-r` only if this is interactive shell:
```bash
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hh \C-j"'; fi
```
2014-01-27 01:27:28 +08:00
To determine the character sequence emitted by a pressed key in terminal,
2014-01-27 01:31:32 +08:00
type `Ctrl-v` and then press the key. Check your current bindings using:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
bind -S
```
2013-12-03 06:55:33 +08:00
* get `hh` in more colors:
```bash
export HH_CONFIG=hicolor
```
show normal history by default (instead of metrics-based view):
```bash
export HH_CONFIG=rawhistory
```
make search case sensitive (insensitive by default):
```bash
export HH_CONFIG=casesensitive
```
more colors and case sensitive search:
```bash
export HH_CONFIG=hicolor,casesensitive
```
2014-01-27 01:14:47 +08:00
* increase the size of history:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:20:47 +08:00
export HISTFILESIZE=10000
export HISTSIZE=${HISTFILESIZE}
```
2014-01-27 01:27:28 +08:00
Variables defined above increase the number of history items and history file size
(default value is 500).
2014-01-27 01:14:47 +08:00
* ensure syncing (flushing and reloading) of `.bash_history` with in-memory
history:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
```
2014-01-27 01:14:47 +08:00
* force appending of in-memory history to `.bash_history`
(instead of overwriting):
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
shopt -s histappend
```
2014-01-27 01:14:47 +08:00
* use leading space to hide commands from history:
2014-01-27 02:30:09 +08:00
```bash
2014-01-27 01:27:28 +08:00
export HISTCONTROL=ignorespace
```
Suitable for a sensitive information like passwords.
2014-01-27 01:14:47 +08:00
2013-12-03 06:55:33 +08:00
BUGS
----
2013-12-03 15:54:19 +08:00
https://github.com/dvorka/hstr/issues