0

Bash on my macOS shows all (probably) commands from $PATH when I double-TAB instead of files and folders. Same when I can use TAB once - it does not work at all. Commands like CD works fine.

I have no idea where the problem is - $PATH seems normal to me:

/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

~/.profile is this:

export PATH=/usr/local/php5/bin:$PATH
export PATH="$HOME/.yarn/bin:$PATH"

~/.bash_profile has only this:

export PATH="/usr/local/sbin:$PATH"

Same behavior under PhpStorm's terminal. So I believe, the problem is somewhere deeper.

Can you help, please?

  • 1
    If you don't type anything else and just hit tab twice, it's expected behavior to get a list of commands instead of files. This is because you're completing a command name and not a filename. – that other guy Apr 01 '18 at 22:21
  • in other words, files and folders will appear with a double tab after a command name `ls -l {tab}{tab}` – LMC Apr 01 '18 at 23:25

1 Answers1

0

Command-line completion in Bash is achieved through readline, a well-known utility library used by many GNU and other Open Source products.

Basic completion is using the {TAB} key, and the actual completion depends on context. If the text does not start with a special character then commands are listed if they match, only if commands don't match are filenames listed.

If completion can be achieved, enough characters are supplied to make the completion unique, then it will be done, otherwise a second {TAB} will give a list of possibilities.

From man bash (Completing):

Bash attempts completion treating the text as a variable (if the text begins with $), username (if the text begins with ~), hostname (if the text begins with @), or command (including aliases and functions) in turn. If none of these produces a match, filename completion is attempted.

cdarke
  • 42,728
  • 8
  • 80
  • 84