Bash – Command completion does not complete the files in the current directory

autocompletebashcommand

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:

abc.txt
ada.txt
afg.txt

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

a2p
a2x
... // bunch more

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

Best Answer

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.

Related Question