Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

2 Answers 2

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

 
discard

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.