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
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.