Bash Auto Completion

Windows Articles

How to install Lighttpd on Ubuntu 20.04?

There are many web services in Unix but we always look for the one that best suits our needs. In this case,...

How to install Docker on Ubuntu 20.04 / Debian 10?

Docker is a fairly popular technology in today's sysadmin. It is logical to think because it means a complete change in the way images...

How to install Mantis Bug Tracker on Ubuntu 20.04?

Hi, folks. In this post, I will help you to install Mantis Bug Tracker on Ubuntu 20.04 If you...

How to install WordPress with Nginx on Ubuntu 20.04?

Hi, folks. In this post, we will help you install Wordpress with Nginx on Ubuntu 20.04. It's a lot easier than you...

Electron 9.0 available

News has arrived that many developers are going to love. And that is that Electron this great cross-platform application framework has released...

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” –

git clone https://github.com/scop/bash-completion.git

cd bash-completion/

Build the tool –

autoreconf -i

./configure

make

make check

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

Install “bash-completion” –

sudo make install

Using “bash-completion”

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

bat /etc/profile.d/bash_completion.sh

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 –

sudo apt i[TAB]

cat /etc/re[TAB]

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

complete -W ‘<autocompletion_codes>’ <command_name>

Let’s see with an example.

complete -W ‘google.com osradar.com’ host

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

Type “host” command –

host [TAB]

host google.com

host osradar.com

Enjoy!

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to install Lighttpd on Ubuntu 20.04?

There are many web services in Unix but we always look for the one that best suits our needs. In this case,...

How to install Docker on Ubuntu 20.04 / Debian 10?

Docker is a fairly popular technology in today's sysadmin. It is logical to think because it means a complete change in the way images...

How to install Mantis Bug Tracker on Ubuntu 20.04?

Hi, folks. In this post, I will help you to install Mantis Bug Tracker on Ubuntu 20.04 If you...

How to install WordPress with Nginx on Ubuntu 20.04?

Hi, folks. In this post, we will help you install Wordpress with Nginx on Ubuntu 20.04. It's a lot easier than you...

Electron 9.0 available

News has arrived that many developers are going to love. And that is that Electron this great cross-platform application framework has released...