I have an environment variable stored in my .bash_profile called $MODULES:
MODULES='/var/www/html/sites/all/modules/
When I am at the bash prompt and I type cp $MOD
and then press TAB to complete, how do I get it to expand to:
sudo cp /var/www/html/sites/all/modules/
...and then I can immediately continue on with a subfolder and tab-complete that as well? Right now, when I do TAB completion it resolves to:
sudo cp \$MODULES/
...which means it's looking for a directory in the current location named "$MODULES", which is obviously not what I want.
/bin/bash
es this old, so you may wish to putshopt | grep -q '^direxpand\b' && shopt -s direxpand
in your~/.bashrc
to account for both Bash < 4.2.29 and Bash ≥ 4.2.29, wheredirexpand
was introduced. source – Kevin E Sep 24 '22 at 22:51