How to install and enable Bash Linux autocompletion

by time news

2023-11-28 19:51:00

Bash (Bourne Again Shell) is undoubtedly the most popular Linux shell out there, it’s no wonder it’s the default shell on many Linux distributions. One of its most charming features is the built-in “auto-completion” support.

Sometimes called TAB completion, this feature allows you to easily complete a command structure. Allows you to type a partial command and then press the key [Tab] to automatically complete the command and its arguments. Lists all multiple completions, when possible.

Like Bash, almost all modern Linux shells come with support for command completion. In this short guide, we will show you how to activate the Bash auto-completion feature on CentOS and RHEL systems.

First, you need to enable the EPEL repository on your system, then install the bash-completion package plus some extras using the YUM package manager, like this one.

# yum install bash-completion bash-completion-extras

Now that you have installed bash completion, you need to enable it for it to start working. First get the bash_completion.sh file. You can use the following locate command to find it:

$ locate bash_completion.sh
$ source /etc/profile.d/bash_completion.sh

Find and get Bash completion

Alternatively, log out of your current login session and log back in.

$ logout

Now the auto completion feature should be working on your system, you can test it as shown below.

$ lo[TAB]
$ ls .bash[TAB]

Note: TAB completion also works for path names and variable names, and is programmable.

That’s all! In this guide, we show how to install and enable the Bash auto-completion feature, also known as TAB completion on CentOS/RHEL. You can ask any questions through the comments section below.

#install #enable #Bash #Linux #autocompletion

You may also like

Leave a Comment