Question
When using cp
command with environment variables, why pressing TAB
for auto-complete doesn't work properly?
Description
I have a directory $HOME/Music
; I want to copy a file from within this directory to the current directory. Therefore:
- I Type
cp $HOM
and press TAB, so it readscp $HOME
; - There is an additional space after
cp $HOME
, therefore I delete it byBackspace
and then type a slash:cp $HOME/
; - Now Press
TAB
createscp \$HOME/
which has a spuriousbackslash
at the beginning of$HOME
. When writing further letters i.e.cp \$HOME/Mu
for Music, TAB doesn't work for autocompletion.
OS: Ubuntu 20.04
~/.bashrc
in an editor 2- add this line at the end of the fileshopt -s direxpand
. 3- save the file, close and open your terminal again; the problem is solved! – Naghi Aug 23 '20 at 14:19