Are you looking for an easy way to find the recently used commands? Are you sick of typing some long commands over and over? Do you want to mange and bookmark the favorite and frequently used commands in the SHELL? Well, look nowhere. Try HSTR - a free and open source utility to view, navigate, search and manage your commandline history. Of course, you can search the your command line history using up/down arrow keys or using CTRL-R (reverse search) and type the search term to find a recently used command in the history. However, Hstr is much more easier than CTRL-R. Read on and you will find out.
For Arch Linux and its derivatives, Hstr is available in AUR. So, the Arch users can install it using any AUR helper tools such as Yay.
$ yay -S hstr-git
CentOS and RHEL users can install it using this command:
$ sudo yum install hstr
The Debian users can install it as shown below.
First, Download and register the key using commands:
$ wget www.clfh.de/frankh.asc $ sudo apt-key add frankh.asc
Then, add the following lines in the sources list:
deb http://www.clfh.de/debian wheezy main deb-src http://www.clfh.de/debian wheezy main
Finally, update the sources list and install hstr using command:
$ sudo apt-get update $ sudo apt-get install hh
Fedora users install it with following command:
$ sudo dnf install hstr
openSUSE Leap 42.1 users run the following as root user to install hstr:
# zypper addrepo http://download.opensuse.org/repositories/home:tuw-e184/openSUSE_Leap_42.1/home:tuw-e184.repo # zypper refresh # zypper install hstr
The Ubuntu and Linux Mint users can install it using Hstr official PPA.
$ sudo add-apt-repository ppa:ultradvorka/ppa $ sudo apt-get update $ sudo apt-get install hh
The other Linux distribution users can install it from source as shown below.
Switch to root user and clone HSTR Git repository with command:
# git clone https://github.com/dvorka/hstr.git
Create build files using:
# cd ./dist && ./1-dist.sh && cd ..
Finally, Install hh using commands:
# ./configure && make && make install
After installing hstr, run the following command to configure it with BASH.
$ hh --show-configuration >> ~/.bashrc
Run the following command to apply the changes.
$ source ~/.bashrc
It's just enough to get going.
For detailed hh configuration documentation, head over to the Configuration page.
View, Navigate, Search And Manage Your Commandline History Using HSTR
To search for the commands in the history, type hstr or hh in the Terminal and hit ENTER.
The hstr utility provides suggest box like functionality for commands used in the past. Type any letter in the prompt, hstr will automatically suggests a list of commands that contains the letter. Use Up/Down arrows to navigate through the history.
You can also directly specify the search patterns along with hh or hstr command in the Terminal. For instance, type the following command to search for commands that has pattern "git".
$ hh git
$ hstr git
You will see the list of suggestions once you hit ENTER key.
To select a command and bring it to the Terminal, use TAB key. Or, choose the command and hit ENTER key to directly execute it.
By default, Hstr parses your .bash-history file that is filtered as you type a command substring. Commands are not just filtered, but also ordered by a ranking algorithm that considers number of occurrences, length and timestamp.
To delete a command from the history file, select it and hit DEL key.
hstr has bookmarking feature. So, you can bookmark your favorite and frequently used commands. To bookmark your favorite command, select the command from the list using up/down arrows, press CTRL-F. The selected command will be marked as favorite.
All bookmarked commands will be saved in ~/.hh_favorites file. To view the bookmarked commands, type CTRL-/ (Control key + / (forward slash)) keys.
To exit from hstr and go back to Terminal, press CTRL-g.
Here is the complete list of key bindings to use HSTR effectively.
- Ctrl-e : Toggle regular expression and substring search.
- Ctrl-t : Toggle case sensitive search.
- Ctrl-/, Ctrl-7 : Rotate view of history as provided by Bash, ranked history ordered by the number of occurrences/length/timestamp and favorites.
- Ctrl-f : Add currently selected command to favorites.
- Ctrl-l : Make search pattern lowercase or uppercase.
- Ctrl-r, UP/DOWN arrows, Ctrl-n, Ctrl-p : Navigate in the history list.
- TAB, RIGHT arrow : Choose currently selected item for completion and let user to edit it on the command prompt.
- LEFT arrow : Choose currently selected item for completion and let user to edit it in editor (fix command).
- ENTER : Choose currently selected item for completion and execute it.
- DEL : Remove currently selected item from the shell history.
- BACSKSPACE, Ctrl-h : Delete last pattern character.
- Ctrl-u, Ctrl-w : Delete pattern and search again.
- Ctrl-x : Write changes to shell history and exit.
- Ctrl-g : Exit with empty prompt.
For more details, check the man pages.
$ man hh
Hope this helps.
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Reddit | Facebook | Twitter | LinkedIn | RSS feeds
Have a Good day!!
“man hh” won’t worked, but “man hstr” do the job …
“hh” is aliased into the bash … 😉