Bash Auto Completion

0
231

When you’re on Linux, the art of “terminal and commands” is a daily dose. The terminal is a powerful solution for the Linux platform that can perform wonders and tons of tasks. It also provides great versatility and control over the system.

In the case of Bash – the most popular shell for Linux, auto code completion isn’t available by default. Bash can run most of the “sh” scripts without any modification. Code auto-completion is a great feature for reducing your load of typing each and every single command as you type. If you’re interested in the code completion, then Fish shell is the best choice.

Despite default code completion, you can still enjoy the feature, thanks to the great “bash-completion”. This tool will enable the auto-completion feature on Bash shell.

Let’s enjoy “bash-completion” shell right away!

Getting “bash-completion”

The “bash-completion” provides all the available pre-built packages for the major Linux distros. Check bash-completion on GitHub.

The following guide will install “bash-completion” from source and it will apply for all the Linux distros.

Grab “bash-completion” –

Build the tool –

At this stage, you may find out some dependency issue. For passing this stage, “pytest” >= 3.6, pexpect, tcllib and dejagnu.

Install “bash-completion” –

Using “bash-completion”

It’s actually a bash script by itself. Check out the code of “bash-completion” –

Bat – a Cat clone https://www.osradar.com/bat-advanced-cat-for-linux/

After the installation is complete, it’s time to enjoy auto code completion. Fire up a terminal –

You can also set your simple bash completion code. The method follows the following structure –

Let’s see with an example.

In the above command, there will be 2 different autocomplete suggestions for “host” (google.com and osradar.com).

Type “host” command –

Enjoy!

Spread the love
  • 6
    Shares

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here