Terminal autocompletion 'tab' not working as intended?

I know this has been discussed on other posts but my problem does not seem to be fully resolved and I do not have permission to add a comment to those posts yet :(

listed on help.ubuntu.com > UsingTheTerminal > Save on Typing:

Tab: "It autocompletes any commands or filenames".

After following the advise from apt-get autocomplete I get results after pressing tab twice but no auto completion for commands or files. Running Xubuntu 13.04.


To enable smart completion

Using sudo and your favorite editor, edit your /etc/bash.bashrc file.

Uncomment the following lines, by removing the # in the beginning of the lines:

#if [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
#fi

Now you can use tab completion to power your way through commands.


it completes file name only if the initials you are providing is unique , and don’t have any other possible file name:

Suppose you have two file file1expo and file2expo in working directory-

then using gedit file<<tab>> will not work because it has two possible outcomes, where as gedit file1<<tab>> will work.

If you want to list all the files starting with initials like xaa then simply use

ls "xaa" 

it will show all the files names with starting characters xaa.


This can be frustrating, that is for sure! One quick and easy workaround would to just use bash instead of sh.

You may be defaulting to using /bin/sh as your shell instead of /bin/bash. Personally I like bash better as it has Tab-autocompletion turned on out of the box.

Check to determine your shell:

$ echo $SHELL
/bin/sh               <-- this may be your issue

Launch bash to ensure this fixes the issue:

bash

Now try the Tab-autocompletion. If it works, then change your default shell from /bin/sh to /bin/bash using the chsh (change shell) command for that user:

chsh -s /bin/bash USERNAME

Logout and log back in. Now all new shells will Tab-autocomplete.