We often use quite complex commands in our terminals. We usually either search for them over and over again, save them somewhere to refer to later, or try to remember them. However, there is another option — to use autocompletion in terminal based on the history of used commands. It’s much easier to set up than you might expect, and it can really save your time and boost productivity.
1. Built-in Unix “reverse-i-search”
Unix system terminal stores the history of recent commands.
For Windows users the new version of Powershell also supports this too.
So we can quickly search in that history list using
CTRL+R or also called “reverse-i-search”:
As you type more the autocomplete will be precising or you can also press
CTRL+R to search for other matching commands.
By default terminal, history will store the last 500 commands, but you can manually set size by setting in your
2. OhMyZsh & zsh-autosuggestions plugin
Another possible option is to use OhMyZsh instead of a built-in shell. It is a kind of shell on steroids that has a bunch of additional configurations, one of which is a zsh-autosuggestions plugin.
- First, install OhMyZsh using official installation instructions
- Then, add the zsh-autosuggestions plugin using installation instructions
Another alternative to the built-in shell is fish-shell, and it is available for macOS, Windows, and Linux. The installation process is as easy as running one command or downloading and running their installer.
I definitely would suggest using at least one of the above options on your everyday work in the terminal, because it worths it. Also, you can combine some of them, like using
OhMyZh autosuggestions with built-in
— P.S: If you find this article interesting, feel free to follow me on Medium as well as on Twitter.