Bash Auto Completion

Windows Articles

How to install Redis on CentOS 8?

Hello, friends in this post, we will show you how to install Redis on CentOS 8 As we well...

How to enable and disable startup applications in Windows 10

Hello! Windows 10 is an attractive and very easy to use system. However, some criticism has come for being too "heavy". That...

How to install Oracle Java 15 on Ubuntu 20.04 / 18.04?

Hello, friends. We know that Java is one of the most popular programming languages and now it's version 15. So in this...

How to run the Linux Tail command in Windows 10.

Hi! The title of this post may seem incongruous, but it's not. In fact, for some time Microsoft has approached positions with...

How to compress large videos in Windows 10

Hello, how are you? Multimedia resources are definitely used in any system. Indeed, we live in the age of technology. That's why...

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 Redis on CentOS 8?

Hello, friends in this post, we will show you how to install Redis on CentOS 8 As we well...

How to enable and disable startup applications in Windows 10

Hello! Windows 10 is an attractive and very easy to use system. However, some criticism has come for being too "heavy". That...

How to install Oracle Java 15 on Ubuntu 20.04 / 18.04?

Hello, friends. We know that Java is one of the most popular programming languages and now it's version 15. So in this...

How to run the Linux Tail command in Windows 10.

Hi! The title of this post may seem incongruous, but it's not. In fact, for some time Microsoft has approached positions with...

How to compress large videos in Windows 10

Hello, how are you? Multimedia resources are definitely used in any system. Indeed, we live in the age of technology. That's why...
x