Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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

share|improve this answer

There is an option for it

shopt -s direxpand

It didn't work on Bash 4.1 (this incompatible feature was added in BASH 4.2), so I used it as

[[ $BASH_VERSION =~ ^4.[2-9] ]] && shopt -s direxpand
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.