$ bash --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
I normally using the above bash version on an Ubuntu 16.04 machine via MATE terminal. Currently however I am using macOS 10.14.6's Terminal.app to SSH in to that machine. The .bash_profile for my user just sources .bashrc so there shouldn't be any configuration differences beside the terminal emulators.
I have environment variables that I use to abbreviate frequently-used but long directory paths, defined in my .bashrc, something like:
export FOO=~/foo/bar/baz
export BAR=~/foo/bar/baz/qux/foobar
I have a habit of using tab-completion (I mean typing part of the name and pressing the tab key) on subdirectories of these variables, so I can type:
cd $FOO/mi<TAB>
and get:
cd $FOO/misc/
This is the behaviour under the MATE terminal that I am used to and like. But using Terminal.app to SSH in to the same machine, it irritatingly expands the variable:
cd /home/andrea/foo/bar/baz/misc/
I don't know why this happens, but I suspect Terminal.app sends a different escape sequence. If I type <ESC><TAB> in Terminal.app instead of <TAB>, I get the familiar and desired behaviour (no expansion of the environment variable). Unfortunately, it doesn't seem like Terminal.app's escape sequence for TAB is configurable.
So, I want to know if I can force bash to always use the behaviour I want.
In the answers to bash: variable name not being expanded with Tab completion (where someone has the opposite problem to me, they want to have the behaviour that I don't want), I have seen shopt -s direxpand. So I tried its inverse, shopt -u direxpand, and it did not help. In https://stackoverflow.com/questions/6418493/bash-variable-expansion-on-tab-complete I saw also shopt -s cdable_vars, but likewise shopt -u cdable_vars did not help.
I am at a loss. :(