If I start typing a command like apt-g after hitting tab, the shell completes the command to apt-get, but for the second part of the command like install, if I enter some characters like insta, hitting tab, doesn't complete it to install.

Another example: after I enter sudo hitting tab doesn't complete anything. for example: sudo apt-ge [tab] and nothing.

I installed Ubuntu using mini iso (40MB network installer), so maybe there is a config that I missed!

I'v added this code to my .bashrc and it didn't work:

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

.bashrc permissions are -rw-r--r--

I ran source .bashrc after the changes but it's still not working.

Editing:

~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml

And changing:

<property name="&lt;Super&gt;Tab" type="string" value="switch_window_key"/>

to:

<property name="&lt;Super&gt;Tab" type="string" value="empty"/>

Doesn't makes any difference.

up vote 57 down vote accepted

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 changes you need to source your ~/.bashrc with source ~/.bashrc or reopen your Terminal. It should be fix now.

  • 1
    I would like to confirm that adding the above block of code to the ~/.bashrc file did work for me. Just one comment; you don't really need to log out and log in again to make it work (you may not want to terminate what you work in), you could just run source ~/.bashrc. – nullgeppetto Dec 1 '16 at 18:35
  • I had to reopen the Terminal in order for it to work! – Gilberto Albino Mar 29 '17 at 13:17
  • 1
    Completion suddenly stopped working for me, the above steps do not fix the issue. Any ideas on how to troubleshoot the issue? On ubuntu 16.04 – Gudlaugur Egilsson Feb 6 at 18:36
  • Step 2 does it for me. Or get the template from /etc/skel/.bashrc – Hendy Irawan May 3 at 15:48

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

  • Tried accepted awnser, but everything was already in place. This was indeed the solution for me. – user1226868 Nov 24 '16 at 14:35
  • Ditto. Great hint. – cerebrou Dec 5 '16 at 6:31
  • Yes! Thank you. – sifferman May 21 '17 at 21:56
  • Thank you so much, I was really losing my mind on this one. – Dustin Cowles Apr 17 at 6:26
  • Still the solution I needed as of May 2018. – clifgray May 28 at 15:06

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

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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