1
$ 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. :(

Andrea
  • 293
  • 2
  • 11
  • Rather than trying randomly suggested shopt variables, have you tried comparing the full list of shopt option values from both terminals to see the differences? There aren't that many of them and you can get the full list by writing `shopt` with no arguments. Their use cases are explained here https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html I believe that's either the fastest way to solution or to the knowledge if shopt options are the culprit. – Marek Rost Mar 19 '20 at 19:18
  • 1
    @MarekRost I read that and it doesn't help. It does seem like `direxpand` should be what I want, yet it doesn't seem to do anything. – Andrea Mar 30 '20 at 20:41

0 Answers0