Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Using Ubuntu 12.04. When I'm typing a path in terminal that starts with an env variable reference, I hit tab to complete a word and it escapes the $ in the env variable reference. As a result, I have to keep on going back to the beginning of the line and removing the backslash so I can continue navigating down a tree.

E.G.

Before Tab: user@test:~$ $HOME/Docum

After Tab: user@test:~$ \$HOME/Documents/

My $HOME/.bashrc has the "bash_completion" stuff enabled.

share|improve this question

closed as off topic by Jorge Castro, Anwar Shah, Amith KK, Gilles, jokerdino Oct 16 '12 at 23:45

Questions on Ask Ubuntu are expected to relate to Ubuntu within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
It seems like you're trying to report a bug. Please read these instructions carefully--they explain how to do this. If your intention is not to report this as a bug but to ask for workarounds to the problem, please clarify that by editing your question (but I still highly recommend reporting it as a bug because that might ultimately be the only way to get the problem fixed). –  Eliah Kagan May 23 '12 at 21:16
    
Same as askubuntu.com/questions/41891/… –  geirha May 23 '12 at 21:49
    
I've been around long enough to know that sometimes "it just works like that" and that there might be a way to make it work differently. My instinct tells me that this isn't just a bug. –  David M. Karr May 23 '12 at 22:05
    
This isn't really an answer, but it seems like a lot of extra typing to refer to $HOME. Why not use ~/Docum<tab> instead? –  Scott Severance May 24 '12 at 7:59
    
Also, for what it's worth, this isn't "just the way it works." I can't reproduce your issue. –  Scott Severance May 24 '12 at 8:01
show 2 more comments

2 Answers 2

It's something with the bash version that comes with Ubuntu 12.04.

I was able to compile bash from source to get my bash version up to 4.2.37, which resolved the issue.

share|improve this answer
add comment

You mention in the comments that your actual problem wasn't with '$HOME'. That's quite important since it matters if it is an environment variable or not.

Bash will complete possible environment variables first if you started with a dollar sign, finally followed by filename completion. So if it couldn't find a variable to complete for you, it could have found a filename, in which case it will escape the dollar sign with a backslash since that's a special character.

If you started your command with a program followed by some variables, completion could be handed over to programmable completion, which could also cause this. For example, typing gzip $HOME/ followed by tab will insert a backslash. The files handling programmable completion are owned by the package 'bash-completion', so either you can uninstall that package (I don't have in installed), or you can convince them it's a bug. Maintainers: http://bash-completion.alioth.debian.org/

Update: on Arch Linux, I tried out bash-completion version 2.0 and that works as expected for ls $HO<TAB>, but not for ls $HOME/<TAB> so I guess they still not solved this bug (Ubuntu uses version 1.3). You can try manually installing version 2.0, but note that it doesn't work completely. (Since the bug report also mentions it could be bash, I'm using version 4.2.37 instead of 4.2.24)

share|improve this answer
add comment

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