hstr/README.md
Martin Dvorak 1715e693f3 Fixing MD.
2014-04-27 08:27:20 +02:00

4.9 KiB

hstr

BASH History Suggest Box - http://www.youtube.com/watch?v=sPF29NyXe2U

DESCRIPTION

Are you looking for a command that you used recently? Do you want to avoid the need to write long commands over and over again despite you used them recently? Are you looking for a tool that is able to manage your favorite commands?

HSTR is a command line utility that brings improved BASH command completion from the history. It aims to make completion easier and more efficient than Ctrl-r.

BASH History Suggest Box

Apart to the completion, history can be managed (you can remove commands that e.g. contain sensitive information like passwords) and bookmark your favorite commands.

UBUNTU INSTALLATION

  • install hh on Ubuntu (12.04LTS/12.10/13.10/14.04LTS):
sudo add-apt-repository ppa:ultradvorka/ppa
sudo apt-get update
sudo apt-get install hh
  • optionally configure hh:
hh --show-configuration >> ~/.bashrc

INSTALLATION FROM SOURCE CODE

  • Clone Git repository:
git clone https://github.com/dvorka/hstr.git
  • create build files using:
cd ./dist && ./1-dist.sh && cd ..
  • install hh using:
./configure && make && make install
  • optionally configure hh:
hh --show-configuration >> ~/.bashrc

DISTRIBUTION INSTALLATION

  • download latest distribution from project Releases section:

https://github.com/dvorka/hstr/releases

  • expand the archive and install hh using:
./configure && make && make install
  • optionally configure hh:
hh --show-configuration >> ~/.bashrc

DEBIAN/MINT INSTALLATION

  • install hh on Debian (Wheezy) or Mint (13) by registering the key:
wget www.clfh.de/frankh.asc
apt-key add frankh.asc

adding the repository:

deb http://www.clfh.de/debian wheezy main
deb-src http://www.clfh.de/debian wheezy main

and installing it:

apt-get update
apt-get install hh
  • optionally configure hh:
hh --show-configuration >> ~/.bashrc

ARCH LINUX

  • download latest distribution from project Releases section:

https://github.com/dvorka/hstr/releases

  • use PKGBUILD in the root of the distribution to build package using makepkg:

https://wiki.archlinux.org/index.php/PKGBUILD

  • install hh
  • optionally configure hh:
hh --show-configuration >> ~/.bashrc

MAC OS

env CFLAGS="-I/opt/local/include -I/usr/include" LDFLAGS="-L/opt/local/lib -L/usr/lib" ./configure
  • finish the installation
make && make install
  • optionally configure hh:
hh --show-configuration >> ~/.bashrc

CONFIGURATION EXPLANATION

  • hh works best with the optional configuration described in this section. You can configure hh just by running:
hh --show-configuration >> ~/.bashrc
  • bind hh to a BASH key e.g. to Ctrl-r:
bind '"\C-r": "\C-ahh \C-j"'

or Ctrl-Alt-r:

bind '"\e\C-r":"\C-ahh \C-j"'

or Ctrl-F12:

bind '"\e[24;5~":"\C-ahh \C-j"'

bind hh to Ctrl-r only if this is interactive shell:

if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hh \C-j"'; fi

To determine the character sequence emitted by a pressed key in terminal, type Ctrl-v and then press the key. Check your current bindings using:

bind -S
  • get hh in more colors:
export HH_CONFIG=hicolor

show normal history by default (instead of metrics-based view):

export HH_CONFIG=rawhistory

show favorites by default (instead of metrics-based view):

export HH_CONFIG=favorites

make search case sensitive (insensitive by default):

export HH_CONFIG=casesensitive

show warnings:

export HH_CONFIG=warning

show debug messages:

export HH_CONFIG=warning

more colors and case sensitive search:

export HH_CONFIG=hicolor,casesensitive
  • increase the size of history:
export HISTFILESIZE=10000
export HISTSIZE=${HISTFILESIZE}

Variables defined above increase the number of history items and history file size (default value is 500).

  • ensure syncing (flushing and reloading) of .bash_history with in-memory history:
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
  • force appending of in-memory history to .bash_history (instead of overwriting):
shopt -s histappend
  • use leading space to hide commands from history:
export HISTCONTROL=ignorespace

Suitable for a sensitive information like passwords.

BUGS

https://github.com/dvorka/hstr/issues