Bash – Why can’t I use tab expansion/auto-complete of shell variables with cd

autocompletebash

I have setup a variable in .bashrc:

export SOME_DIR=/path/to/some/dir

Now, with ls I can type ls $SOME_DIR[tab] and the variable will be expanded, and I can then use tab for auto-completion when going deeper into the filesystem.
However, if I try cd $SOME_DIR[tab] or cd $SOME_DIR/[tab], nothing happens.

Why does this only work with ls? Is it possible to make it work with cd?
I have tried adding shopt -s direxpand to .bashrc, to no effect:

Best Answer

Apparently shopt -s direxpand works with everything except the built-in cd. So I just added alias xy=cd to my profile, and xy works just like cd except direxpand works using TAB. (Who would have thought it would be so simple?)