McFly – Fly through your shell history

This is nothing but a replacement to your Bash search history feature. Most of us use Reverse bash command “Ctrl + R” in order to search and find the most day to day used terminal commands.

Using bash reverse search, as used in most of the Linux distro’s we can bring up all commands which we used previously executed without having to re-type them every time. Other thing is that you may use UP/DOWN arrows to search your bash history. However, Ctrl + R will make this process much easier and faster. Today, I Stumbled upon a replacement to “Ctrl + R” Bash history search feature. Meet “McFly”, a simple tool written in Rust programming language that replaces the default Ctrl + R Bash history search with an intelligent search engine. All command suggestions made by McFly are prioritised in real time with a small neural network.

McFly can be installed using Linuxbrew on Linux. If you haven’t installed Linuxbrew yet, refer this following link.

Once Linuxbrew installed, run the following commands to install McFly:

$ brew tap cantino/mcfly https://github.com/cantino/mcfly
$ brew install mcfly

After the installation is completed, you will see the following output.

==> Installing mcfly from cantino/mcfly
==> Downloading https://github.com/cantino/mcfly/releases/download/v0.2.5/mcfly-v0
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.c
######################################################################## 100.0%
==> ONE MORE STEP! Edit ~/.bashrc and add the following:

if [ -f $(brew --prefix)/opt/mcfly/mcfly.bash ]; then
. $(brew --prefix)/opt/mcfly/mcfly.bash
fi
 /home/linuxbrew/.linuxbrew/Cellar/mcfly/v0.2.5: 4 files, 3.5MB, built in 33 seconds

As you can see, we need to do one more step before start using McFly.

Add the following lines to your ~/.bashrc file:

if [ -f $(brew --prefix)/opt/mcfly/mcfly.bash ]; then
. $(brew --prefix)/opt/mcfly/mcfly.bash
fi

Finally, run the following command to take effects changes:

$ source ~/.bashrc

Your BASH history will be imported to McFly database when you run this command for the first time. It will take a few moments depending upon size of your bash history file. Once the import is done, you will see the following message.

McFly: Importing Bash history for the first time. This may take a minute or two...done.

Voila ! Now you can now start using McFly, Let’s go…

The below mentioned gif shall give you a fair idea of all what’s it about.(Courtesy:- ostechnix).

Have fun & stay tuned for more good things about Linux !

Leave a Reply

Your email address will not be published. Required fields are marked *