10

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?

4
  • aptitude is not equal to apt. Which one is problematic?
    – Lekensteyn
    May 7, 2012 at 9:44
  • Apologies. Apt commands in general.
    – beanaroo
    May 7, 2012 at 9:50
  • Is completion set up for apt-get? complete -p apt-get
    – geirha
    May 8, 2012 at 17:00
  • The result reads: 'complete -F _apt_get apt-get' Not sure what that means
    – beanaroo
    May 11, 2012 at 14:44

4 Answers 4

17

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
3
  • I can't find any /etc/bash.bashrc. You sure about that?
    – jokerdino
    Sep 22, 2012 at 2:01
  • 1
    Adding those lines to ~/.bashrc should work, too. Jul 14, 2016 at 17:53
  • Relogin was required, but then it worked!
    – My-Name-Is
    Jan 13, 2018 at 19:35
12

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.

2
  • 1
    It works, but I don't get why, the el stands for Emacs Lisp... Jul 14, 2014 at 9:29
  • Any ideas about autocompletion for apt itself? (as opposed to apt-get) Jan 26, 2015 at 15:02
2

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*
1
  • 3
    Dear Downvoter, please leave a comment helping me avoid repeating, the perceived mistake. Mar 13, 2016 at 13:16
2

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).

2
  • 1
    Is this a question or an answer? May 23, 2017 at 11:07
  • Rephrased to read more like an answer
    – Felix Hall
    May 23, 2017 at 19:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .