Bash and Tab Auto-complete

autocompletebash

I recently put Fedora Core 15 on my system, and I've had a behaviour change that I can't figure out. Using Tab-Complete in the BASH shell works fine except when I use the $HOME variable.

If I type cd $HOME/dTAB, it will auto-complete to the proper directory (doc), but it also inserts a preceding \, so the result is cd \$HOME/doc. This then fails, as such a path does not exist.

The error is

bash: cd: $HOME/doc: No such file or directory

If I don't use Tab-Complete it works, as $HOME still points to the proper directory. Where did this extra \ come from, and how do I make it go away?

Best Answer

By issuing the command complete you'll get the list of all completion definitions. Then you can search the offending definition somewhere in /etc/bash_completion and /etc/bash_completion.d. There can be also some .bash_completion in your home directory. On my system the $HOME variable is completed properly, but then fails to complete anything.

Did you try to use ~ instead of $HOME? It's easier to type and it works as expected...