I think what you're really looking for is context-aware tab completion for Bash commands. For example, .DS_Store
is a regular file, not a directory, so it should not show up as a possible completion to cd
.
The package that solves this problem is called bash-completion
. I use Fink's version (fink install bash-completion
), and it's also available from MacPorts (port install bash-completion
) and Homebrew (brew install bash-completion
).
After the package is installed and configured in your .bashrc or .bash_profile, regular files will no longer show up as completions for cd, and many other common bash commands become context aware as well (eg. gunzip
).
cd
in Terminal then key Tab twice: there's a prompt before all possibilities (not only directories) are listed.cd */
followed by two tabs lists all subdirectories of the current directory. But you have to backspace to select one...cd
was smart enough to only list directories by default.