Adding auto complete for apt-get install

Question:

I have noticed that while on Ubuntu, if I type the following:

mc

and it isnt installed, I get the message below:

The program 'mc' is currently not installed. You can install it by typing: sudo apt-get install mc

However in Debian, that is not available. It just gives a “-bash: /usr/bin/mc: No such file or directory” message. How can I implement the same functionality in bash command line on Debian? Yes, I know that if it is package suggestion that I want, I can simply do a regex search using *apt-cache search*. However I was hoping for the simpler suggestion immediately on typing the name of the program.

As per discussions, the functionality is provided by the package command-not-found. However even after installing it, and also installing bash-completion package, this isnt available on the Debian bash shell.

Answer:

The suggestions are definitely provided by the package command-not-found.

However after installing the package, one needs to run the following command once to initialize the database:

update-command-not-found

After doing this, bash starts providing suggestions to install the correct package.

$htop
Could not find the database of available applications, run update-command-not-found as root to fix this
htop: command not found

$update-command-not-found
Downloading complete file http://ftp.de.debian.org/debian/dists/squeeze/Contents-i386.gz
I: Writing data for ftp.de.debian.org_debian_dists_squeeze_Contents-i386.gz ... . done

$htop
The program 'htop' is currently not installed. You can install it by typing:
apt-get install htop
htop: command not found