Ran into another little snag in Kali Linux on WSL. It seems that I has to manually Enable Bash Autocomplete in Kali Linux for WSL or as the old Linux ways goes, install bash-autocompletion. Bash autocomplete is a handy feature that saves you time and keystrokes whilst working with the command line in Kali Linux. This powerful functionality allows you to press the Tab key to automatically complete commands, filenames, directory paths, and even command options. Let’s walk through the straightforward process of enabling and configuring this essential feature on your Kali Linux system.
Table of Contents
Setting Up Bash Autocomplete
Enabling bash autocomplete in Kali Linux is a simple process that requires just a few steps. Here’s how to get it working properly:
Install the Required Package
First, you’ll need to install the bash-completion package, which provides the core functionality:
┌──(blackmore㉿kali)-[~]
└─$ sudo apt update
[sudo] password for blackmore:
Hit:1 http://http.kali.org/kali kali-last-snapshot InRelease
All packages are up to date.
Install bash-completion
┌──(blackmore㉿kali)-[~]
└─$ sudo apt install bash-completion
Installing:
bash-completion
Summary:
Upgrading: 0, Installing: 1, Removing: 0, Not Upgrading: 0
Download size: 319 kB
Space needed: 1,999 kB / 1,025 GB available
Get:1 http://mirror.lagoon.nc/kali kali-last-snapshot/main amd64 bash-completion all 1:2.16.0-7 [319 kB]
Fetched 319 kB in 1s (444 kB/s)
Selecting previously unselected package bash-completion.
(Reading database ... 30496 files and directories currently installed.)
Preparing to unpack .../bash-completion_1%3a2.16.0-7_all.deb ...
Unpacking bash-completion (1:2.16.0-7) ...
Setting up bash-completion (1:2.16.0-7) ...
This package contains scripts that enable command completion for many common Linux programs and utilities.
Configure Your Shell
Once the package is installed, you need to ensure your shell configuration knows to use it:
- Open your bash configuration file:
nano ~/.bashrc
- Add the following line at the end of the file:
source /usr/share/bash-completion/bash_completion
- Save the file by pressing Ctrl+O, then Enter, and exit with Ctrl+X.
Apply the Changes
To apply the changes without having to log out and back in:
source ~/.bashrc
Verify the Installation
To confirm that bash-completion is working properly:
type _init_completion
If you see information about the _init_completion function rather than an error message, the installation was successful.
Using Bash Autocomplete
Now that you’ve set up bash autocomplete, here are some ways to use it:
- Command completion: Type the first few letters of a command and press Tab.
- File/directory completion: Type the beginning of a file or directory path and press Tab.
- Option completion: Type a command followed by a hyphen and press Tab to see available options.
- Double Tab: Press Tab twice quickly to show all possible completions when there are multiple matches.
Benefits of Bash Autocomplete
Enabling bash autocomplete offers several advantages:
- Reduces typing errors
- Speeds up command line operations
- Helps discover available commands and options
- Makes navigating the filesystem quicker
- Improves overall productivity when working with the terminal
Conclusion
Bash autocomplete is an essential productivity tool for anyone working with Kali Linux or any other Linux distribution. By following these simple steps, you can significantly improve your command line experience and work more efficiently. The few minutes spent setting up this feature will save you hours of typing and searching in the long run. Funny thing, I am quite sure I have always seen this feature enabled in Modern Kali Linux since v 1.0.6. Something changed …. anyway, hope it helps. Enjoy.