apt-get install and apt-cache policy do not complete package names.

I have double checked /etc/bash.bashrc, no irregularities.

Googled for answers but none suffice.

Any help/advice?

share|improve this question
    
aptitude is not equal to apt. Which one is problematic? – Lekensteyn May 7 '12 at 9:44
    
Apologies. Apt commands in general. – beanaroo May 7 '12 at 9:50
    
Is completion set up for apt-get? complete -p apt-get – geirha May 8 '12 at 17:00
    
The result reads: 'complete -F _apt_get apt-get' Not sure what that means – beanaroo May 11 '12 at 14:44
up vote 10 down vote accepted

Actually, I found the solution ~

Install the auto-complete-el

sudo apt-get install auto-complete-el 

Install via the software center

After installing this package, I got everything back to normal.

share|improve this answer
    
100% - many thanks – beanaroo May 16 '12 at 10:47
1  
It works, but I don't get why, the el stands for Emacs Lisp... – Gerhard Burger Jul 14 '14 at 9:29
    
Any ideas about autocompletion for apt itself? (as opposed to apt-get) – Robin Winslow Jan 26 '15 at 15:02

Open /etc/bash.bashrc with gedit or other text editor and uncomment the following lines:

#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
#    . /etc/bash_completion
#fi

It works for me.

On Ubuntu 16.04 the it looks like this:

#if ! shopt -oq posix; then
#  if [ -f /usr/share/bash-completion/bash_completion ]; then
#    . /usr/share/bash-completion/bash_completion
#  elif [ -f /etc/bash_completion ]; then
#    . /etc/bash_completion
#  fi
#fi
share|improve this answer
    
I can't find any /etc/bash.bashrc. You sure about that? – jokerdino Sep 22 '12 at 2:01
1  
Adding those lines to ~/.bashrc should work, too. – LittleByBlue Jul 14 '16 at 17:53

Is your shell prompt looking like $ instead of user@host:~$? If yes, then it could be case of wrong shell causing problem with autocompletion. Try changing login shell to /bin/bash from /bin/sh as below.

sudo chsh -s /bin/bash *username*
share|improve this answer
3  
Dear Downvoter, please leave a comment helping me avoid repeating, the perceived mistake. – Kiran Mar 13 '16 at 13:16
    
This works for me :) thanks. – John Doe Jul 7 '17 at 14:59

The cause might be that you are missing the package bash-completion. In that case, you can try installing it with

sudo apt-get install bash-completion

followed by

source ~/.bashrc

for enabling it. (Or just log out and in again).

share|improve this answer
1  
Is this a question or an answer? – Pierre.Vriens May 23 '17 at 11:07
    
Rephrased to read more like an answer – Felix Hall May 23 '17 at 19:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.