Bash Tab Auto-complete not working for apt

19,942

Solution 1

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.

Solution 2

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

Solution 3

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

Solution 4

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:
19,942

Related videos on Youtube

beanaroo
Author by

beanaroo

Updated on September 18, 2022

Comments

  • beanaroo
    beanaroo almost 2 years

    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?

    • beanaroo
      beanaroo about 12 years
      Apologies. Apt commands in general.
    • geirha
      geirha about 12 years
      Is completion set up for apt-get? complete -p apt-get
    • beanaroo
      beanaroo about 12 years
      The result reads: 'complete -F _apt_get apt-get' Not sure what that means
  • jokerdino
    jokerdino almost 12 years
    I can't find any /etc/bash.bashrc. You sure about that?
  • Sajesh Kumar
    Sajesh Kumar almost 10 years
    It works, but I don't get why, the el stands for Emacs Lisp...
  • Robin Winslow
    Robin Winslow over 9 years
    Any ideas about autocompletion for apt itself? (as opposed to apt-get)
  • kiranpradeep
    kiranpradeep over 8 years
    Dear Downvoter, please leave a comment helping me avoid repeating, the perceived mistake.
  • LittleByBlue
    LittleByBlue almost 8 years
    Adding those lines to ~/.bashrc should work, too.
  • Pierre.Vriens
    Pierre.Vriens about 7 years
    Is this a question or an answer?
  • Felix Hall
    Felix Hall about 7 years
    Rephrased to read more like an answer
  • My-Name-Is
    My-Name-Is over 6 years
    Relogin was required, but then it worked!