Enable Tab Completion in Debian
autocompletion is literally what it’s name might suggest, you start to type something and it’s completed for you.This is usually enabled for simple things such as file and directory names, and by default it will be activated by the “TAB” key.For example if you wish to look at the system’s password file you might wish to run:
less /etc/passwd
To save keystrokes you can actually type:
lesTAB /eTAB/passTAB
As you proceed to type the words pressing TAB will automatically complete things for you.
In the Debian bash package there is a file installed called /etc/bash_completion, this adds a lot more useful behaviours to bash including:
- Auto completion of hostnames, for SSH
- Auto completion of Debian specific utilities
To cause your shell to use it run the following command, then login again:
echo ‘. /etc/bash_completion’ >> ~/.bashrc
This will now give you a lot more completions, most usefully I find the following :
apt-get upgTAB
This becomes the familiar “apt-get upgrade“, other apt-get, and dpkg commands suddenly understand completion too, so instead of typing “dpkg --search” you can cut this down to “dpkg --seaTAB“.
To be honest I don’t know the full extent of the completion offered as some of the code in the /etc/bash_completion file is pretty hard to follow, but I know it saves me time.
Why not have a look yourself?