How do I restore tab-completion on shell variables on the bash command-line?
Posted
by
Eric
on Super User
See other posts from Super User
or by Eric
Published on 2012-10-24T21:56:14Z
Indexed on
2012/10/24
23:04 UTC
Read the original article
Hit count: 228
bash
|tab-completion
I've long set my most-recently visited directories to shell variables d1, d2, etc.
On an ancient Fedora machine I could type a command like
$ cp $d1/
and the shell would replace $d1 with text like /home/acctname/projects/blog/ and would then show me the contents of .../blog, like any tab-completion.
Now, both ubuntu wheezy/sid and fedora 16 just -escape the '$', and naturally there are no completions to show.
You can see this behavior in action in an OSX Terminal window. On 10.8, do something like
ls $HOME/ to see what I mean.
Is there a bash shell variable or option that can restore the old behavior?
man bash
suggests this is a bug:
complete (TAB)
Attempt to perform completion on the text before point. Bash
attempts completion treating the text as a variable (if the text
begins with $), username (if the text begins with ~), hostname (if
the text begins with @), or command (including aliases and functions)
in turn. If none of these produces a match, filename completion is
attempted.
I get the above described completion when a token starts with '~' or a letter. It's just '$'-completion that's broken.
© Super User or respective owner