Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Something is wrong with my tab completion.

Let's say I do this:

cd test // works fine, go into test directory
ls // works fine, displays all of the files

Let's assume I have the following files:


If I type a and then TAB for auto complete, it displays something different like:

... // bunch more

I feel like it thinks I'm in a different directory?

share|improve this question
up vote 11 down vote accepted

Those are commands. If you start typing on the commandline and hit Tab, it won't expand the subdirectories and files of your location but available commands.

Basically, tab completion is context sensitive. If you just start writing and hit Tab, it will complete commands found in your $PATH. If you have already written a command, cd for example, it will complete the files and directories in your current location. For some commands, it will also complete available options to that command.

share|improve this answer
Note that the "double tab" while entering a path may match the OP behavior expectation: it will list all the files available in the currently displayed directory. – Laurent C. Mar 6 '14 at 15:18
@LaurentC. only if you have set ./ to be in your $PATH and even then, only the executable files. – terdon Mar 6 '14 at 15:20

Bash completion does not work as you expect. I will try to give a rough explanation.

When you are typing a command (or if you haven't written anything yet) and press the tab key, bash try to complete with any of the available commands on your $PATH (a2p and a2x are just two commands). Once you have written your command, if you press the tab key again it will try to complete with the arguments for that command (the directory test in your example is an argument to cd).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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