If there's one functionality of bash that most beginners don't know but get very excited about when they discover it, it's history. First you learn to go through the history by pressing up and down, then you find out that
CTRL+R is the spell that gives you access to write commands and find them from history.
I'm a huge fan of that. Probably 80-90% of my bash command history is repeating commands over and over again. Whether it's
npm run start,
git add . or something similar, I can find it from my history.
But the built-in search isn't always the optimal one. You can't really see the history: you have to know what you're looking for. Luckily, developer community is amazing and Andrew Cantino has built a tool to augment your bash history.
Meet McFly. Great Scott!
Instead of being faced with blank black prompt, you get nice visual view of your history. You can search by writing a part of the command, you can navigate with arrow keys and either run (ENTER) or edit (TAB) your commands.
It also features a smart system that takes into account certain things to be more relevant: in which directory you are, what's the context of the command, if the command has failed or not, etc.
In the beginning, mcfly felt a little bit slower because it takes a moment to start up. But after using it a while, I don't want to go back to guessing game.
Top comments (4)
I've been using fzf with some keybindings. The added benefit is that
fzfis a general purpose fuzzy autocomplete engine, it possible to pick a directory or a file in a similar fashion. It's pretty snappy too.
Thanks for sharing Dmitry! I'll have to check it out and give it a go.
McFly looks great.
Makes it easy to visually find the command you're after by showing a list.
Thanks for sharing!
I've been using this in my ~/.bash_profile for an easier
CTRL+Rexperience using the up arrow.
It completes from your bash history using the up keyboard key.
If you've cycled through a few commands pressing the down arrow brings the previously cycled commands back.
That's such a smart improvement, thanks for sharing!