hui
is command-line tool to quickly search through your terminal history. The motivation behind this tool was having a prettier and faster way to do history | grep <search>
. I would do this frequently to remember some docker
or curl
command I had done recently, but couldn't remember the flags I used. This now lets me search through my history and copy the command I want a lot easier.
hui
is built on top of ratatui for its TUI, or Terminal User Interface.
If you are on a Mac, you can install from homebrew
:
brew tap jmwoliver/hui
brew install hui
Alternatively, you would like to install from source if you have cargo
installed locally:
git clone https://github.com/jmwoliver/hui.git
cd hui
cargo build --release
# you can then alias the command so it is available in any directory:
# alias hui=<CURRENT_DIR>/target/release/hui
After installing hui
, it will need to know which shell you are using. This can be done by setting the HUI_TERM
environment variable.
For zsh
, run the following commands:
echo 'export HUI_TERM="zsh"' >> ~/.zshrc
source ~/.zshrc
If you are using bash
, run:
echo 'export HUI_TERM="bash"' >> ~/.bashrc
source ~/.bashrc
Bash doesn't automatically write the history back to the .bash_history
file like ZSH does. The following can be added to your .bashrc
file to append the history for each command (based on a StackExchange response):
unset HISTFILESIZE
HISTSIZE=3000
PROMPT_COMMAND="history -a"
export HISTSIZE PROMPT_COMMAND
shopt -s histappend
Then remember to:
source ~/.bashrc
Once everything is installed and the HUI_TERM
environment variable is set, all you have to do to run it is:
hui
Now you can scroll through all your history, filter results, and select a command to copy to your clipboard.
Enjoy!
I used several projects for inspiration or guidance: