Saturday, 25 April 2009

Bash completion in Ubuntu - auto complete shell commands

Every time I install a new version of Ubuntu, I need to do a few things in order to get my system working like I want it to. One of the most useful things is auto completion in the shell. With this enabled, you no longer need to type an entire sequence of commands. For example, 'sudo apt-g ins' will correctly auto complete to 'sudo apt-get install'. Getting this to work is really easy. I just keep forgetting how to do it and need to look it up every six months. So even though the information is available out there, I'm going to put it up here for my own benefit.

All you need to do is to uncomment the following lines in /etc/bash.bashrc (for me, these were lines 32-34) as root and save the file.

#if [ -f /etc/bash_completion ]; then 

#    . /etc/bash_completion 

#fi

Once this is done, close the current shell and open a new one. Auto complete should work from there on.

No comments:

Post a Comment