Terminal autocomplete doesn't work properly

bash-completion is a set of bash scripts which enables customized completion for specific commands.

This is not just for files and directories, but also e.g. for the commands. So you type partial of commands and by hitting Tab we get a auto completion of commands.

Installation

Step 1: Install bash-completion

$ sudo apt-get install bash-completion

And some times it works if we re-installed it by the follwing command:

$ sudo apt-get install --reinstall bash-completion

Step 2: Enable bash-completion in your .bashrc file

Open your gedit ~/.bashrc and if these content doesn't exist there, add them at the end of it and save it.

# enable bash completion in interactive shells
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

Important: After changing the file you need to source your ~/.bashrc with source ~/.bashrc or reopen your Terminal. It should be fixed now.


If your case is terminal tab not working under Xfce, the solution is as follows:

  1. Open Application Menu > Settings > Window Manager.
  2. Click on 'Keyboard' tab.
  3. Clear the 'Switch window for same application' setting.

Window Manager screenshot how to clear switch window for same application

I've found the solution here.


You may also be in a shell that doesn't support auto complete (ex: Bourne Shell | SH). If you want BASH auto complete you need to switch shells, say to BASH (Bourne Again SHell) instead with the command

chsh -s /bin/bash

Source: Ubuntu Wiki - Changing Shells