Super User is a question and answer site for computer enthusiasts and power users. 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

On a remote computer with bash version "3.2.51(1)-release" (OS: SUSE Linux Enterprise Server 11.1 (x86_64)), I could not do a usual tab completion with variable name. for example, I'd like to type:

echo $OLDPWD/

then at the end of the slash, I can hit "Tab" and the variable name would be expanded to the old directory name (before the last cd or pushd command). This works in my own laptop (Debian 7, Bash 4.2.37(1)-release). Why in this SLES bash shell it would not work?

Similarly, if I type

echo $OLDP

and then hit "Tab" at the end of the "P" there, bash would complete that to $OLDPWD. This would not happen in SLES 11 bash too.

What control variables (shopt? set?) that affect this behavior?

share|improve this question
Does Alt+$ work? – demure Jun 5 '13 at 16:53
Probably the older bash version does not have all the fancy completion functions included. Can you install the bash-completion package on the remote machine? – glenn jackman Jun 5 '13 at 20:06
@glennjackman: The bash-completion package provides a set of wrappers around many commands that customize the argument completion behavior for those commands. It does not affect the completion of environment variables. That capability is built into later versions of bash. – garyjohn Jun 5 '13 at 22:56
Is $OLDPWD set? In my bash 4.2.25 it is not defined until you've used cd at least once. I don't know if bash 3.x set $OLDPWD when you did cd. Does completion of, say, $HOM<tab> complete to $HOME? – Wandering Logic Jun 6 '13 at 2:07

shopt -s direxpand will make echo $HOME/<tab> expand to echo /home/matt/ in bash 4.2. In bash 4.1 it should be the default.

I find that bash-completion can really mess things up. I always either uninstall bash-completion or run complete -r to make sure that the individual completion rules aren't doing something stupid to the default completions.

If $OLDPWD is actually set then echo $OLDP<tab> should expand to echo $OLDPWD. I don't know what would keep that from happening.

share|improve this answer

Try C-x $ instead of TAB to explicitly request possible variable (not something else) completions.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .