Bash (Bourne Again Shell) is undoubtedly the most used shell out there, no wonder it is the default shell on many Linux distributions. One of its most charming features is the built-in “auto-completion” support.
Sometimes referred to as TAB completion, this feature permits you to easily complete a command structure. It allows typing a partial command, then pressing the [Tab] key to auto-complete the command and it arguments. It lists all multiple completions, where possible.
Just like Bash, nearly all modern Linux shells ship in with command completion support. In this short guide, we will show you how to turn on the Bash auto-completion feature in CentOS and RHEL systems.
To make working on the command line super easy for you, this is one of the many things you ought to do while performing:
- Initial Server Setup and Configurations on RHEL 7
- Initial Server Setup and Configurations on CentOS 7
# yum install bash-completion bash-completion-extras
Now that you have installed bash completion, you should enable it to start working. First source the bash_completion.sh file. You can use the locate command below to find it:
$ locate bash-completion.sh $ source /etc/profile.d/bash_completion.sh
Alternatively, logout of your current login current session and re-login.
Now the auto-completion feature should be working on your system, you can try it out as shown below.
$ lo[TAB] $ ls .bash[TAB]
Note: TAB completion works for path names and variables names as well, and it is programmable.
That’s all! In this guide, we showed how to install and enable the Bash auto-completion feature, also known as TAB completion in CentOS/RHEL.