0

I'm using MSYS on Windows 7 and I really enjoy the TAB auto-completion feature of the bash console. However it appears that this feature queries all directories in Windows' $PATH variable, requiring me to narrow down my choice considerably.

Is there a way to have bash only consider files within the current directory?

4
  • Does this happen for all commands or only when auto-completing for cd?
    – terdon
    Feb 6, 2014 at 16:06
  • It does not happen for cd (i hadn't noticed that this works correctly, sorry), but when typing plain names (e.g. of an executable to run)
    – Adrian
    Feb 6, 2014 at 16:23
  • So what were you expecting? Auto-completion of a command name works by looking through all directories in the $PATH. Do you want to only auto-complete executables in the current directory? Is this only about auto-completing executable names then?
    – terdon
    Feb 6, 2014 at 16:31
  • Yes, only completion of files in the current directory. I don't need hints for files elsewhere. It is the behavior I would have expected, but not the default I take it.
    – Adrian
    Feb 6, 2014 at 16:38

1 Answer 1

1

In bash (and all other shells that have auto-completion as far as I know), when you start typing the name of a command and hit Tab, the shell will search through the directories in the $PATH and return the commands whose name starts with what you typed. That way, you can run a command without having to be in the same directory where that particular executable is located. This makes your life much much easier.

If you are only interested in executable files in the current directory, just add a ./ to the beginning of the name you type. ./ means the current directory (at least on *nix systems, I'm not sure if they've changed the format when porting to windows) so bash will try to expand file names in the current directory:

$ ls
foo.pl
$ foo <TAB> ## lists many possible completions
$ ./foo <TAB> ## only lists foo.pl
1
  • I wasn't aware of ./, that's good enough, thanks!
    – Adrian
    Feb 6, 2014 at 17:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .