Bash Auto Completion

Windows Articles

Learn how to control the volume of Windows using the mouse wheel.

Hi! Windows recently celebrated its 35th anniversary. Therefore, it is one of the longest lasting and most used systems currently. On the other hand,...

Install Nim programming language on Ubuntu 20.04 / Debian 10

Nowadays, almost everything is done with the help of a computer and a program. And the programs are made through a programming language. That...

Configure Samba File share Services with Ubuntu 20.04 LTS

Here, Today! let's discuss samba file share service with Ubuntu 20.04 LTS. If you need to share files between Linux and MS Windows...

Install Matomo on Ubuntu 20.04

Hello, friends. In this post, you will learn how to install Matomo on Ubuntu 20.04. It's quite useful to measure the traffic to our...

How to change DNS in Windows 10

Hi! Today we will talk a bit about networks. In fact, we will touch on a topic related to connectivity. Specifically we will see...

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

Learn how to control the volume of Windows using the mouse wheel.

Hi! Windows recently celebrated its 35th anniversary. Therefore, it is one of the longest lasting and most used systems currently. On the other hand,...

Install Nim programming language on Ubuntu 20.04 / Debian 10

Nowadays, almost everything is done with the help of a computer and a program. And the programs are made through a programming language. That...

Configure Samba File share Services with Ubuntu 20.04 LTS

Here, Today! let's discuss samba file share service with Ubuntu 20.04 LTS. If you need to share files between Linux and MS Windows...

Install Matomo on Ubuntu 20.04

Hello, friends. In this post, you will learn how to install Matomo on Ubuntu 20.04. It's quite useful to measure the traffic to our...

How to change DNS in Windows 10

Hi! Today we will talk a bit about networks. In fact, we will touch on a topic related to connectivity. Specifically we will see...
x