How to install Mcfly on Linux.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. Sysadmin and devops need a lot from the terminal. It is impossible to work in this area without knowing terminal tricks. Today I will help you with another one of these. In this post, you will learn how to install Mcfly on Linux. This utility allows you to examine your bash or zsh history at deep levels and is useful to know those commands you have forgotten or to examine what you have done with the terminal.

What is McFly?

According to the Github profile of the application

McFly replaces your default ctrl-r shell history search with an intelligent search engine that takes into account your working directory and the context of recently executed commands. McFly’s suggestions are prioritized in real time with a small neural network.

This means that thanks to this small and useful application, we will be able to access the command history of our shell and recover lost commands and execute them again. This search can be limited and if something makes McFly a marvel is the ease of use.

Some of the main features of McFly are

  • Rebinds ctrl-r to bring up a full-screen reverse history search prioritized with a small neural network.
  • Augments your shell history to track command exit status, timestamp, and execution directory in a SQLite database.
  • Maintains your normal shell history file as well so that you can stop using McFly whenever you want.
  • Unicode support throughout.

Also, You can type % to match any number of characters when searching.

So this tool can become essential for all sysadmin and devops who use the terminal intensively.

Let’s go for it.

Install McFly on Linux

Fortunately, the installation of McFly on Linux is quite simple and there are several methods available.

The first is using Homebrew which is an alternative package manager but is safe to use on Linux.

However, in this post, we will use an installation script provided by the developers themselves.

So, connect via SSH to your server as root user or if you are using the system on the desktop, then after upgrading it run

curl -LSfs https://raw.githubusercontent.com/cantino/mcfly/master/ci/install.sh | sh -s -- --git cantino/mcfly
1.- Download and install Mcfly on Linux
1.- Download and install Mcfly on Linux

If everything went well, you will see the following output.

To complete the installation, simply edit the ~/.bashrc file to add a line.

So, open the file mentioned above.

nano ~/.bashrc

And at the end of the whole file, add

eval "$(mcfly init bash)"

Save the changes and close the editor.

To complete the process you have to apply the changes by running

source ~/.bashrc

And you should see the following output to verify that everything is OK.

2.- Applying McFly
2.- Applying McFly

Using McFly on Linux

After the installation has been successful then you can use it without any problems.

As mentioned above, McFly is very easy to use.

All we have to run is the command and a search criteria. For example

mcfly search apt
3.- McFly on Linux
3.- McFly on Linux

In this case, it will search the bash history for all the commands that have been executed that are related to APT.

In my case, this will produce a screen output like this

At the bottom, you can see the history of the commands related to APT.

You can scroll the screen using the arrow keys. And to execute one of those commands, then once selected press the Enter key.

Also, you can remove the command from the history by pressing the F2 key. To exit McFly press the ESC key.

Sometimes it happens that if our bash history is overloaded, we are not interested in showing so many commands. So, it is advisable to limit the number of results. To do so, run

export MCFLY_RESULTS=50

Replace 50 with the desired number. Yes, McFly uses environment variables to configure itself.

You can also make McFly faster by limiting the number of commands examined in history.

export MCFLY_HISTORY_LIMIT=5000 

So you can configure McFly a little bit.

Conclusion

This tool is quite useful for working with the terminal. So, enjoy it.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook