Reputation: 147
Please, tell me, what should i do , to interpolate variable name in bash command line while I type it?
i.e. $A = ~/tmp/
in tmp folder I have tmp1 and tmp2 folders.
I type: cd $A<TAB>
and nothing happes.
if i put additional / and type cd $A/tmp1
, it will put additional space at the end cd $A/tmp1<space>
.
I want the following behavoir:
cd $A<TAB>
=====> cd ~/tmp/<without additional space>
Any suggestions?
Upvotes: 0
Views: 1527
Reputation: 123528
You need to say:
shopt -s direxpand
Now saying:
cd $A/TAB
(note the /
before TAB) would present directories without adding space.
From the manual:
direxpand
If set, bash replaces directory names with the results
of word expansion when performing filename completion.
This changes the contents of the readline editing buf‐
fer. If not set, bash attempts to preserve what the
user typed.
Moreover, instead of setting a variable by saying:
A="~/tmp"
or
A=~/tmp
say
A="${HOME}/tmp"
Upvotes: 2
Reputation: 27577
Firstly, you don't want any spaces on either side of your =
. Secondly, I have no problem with bash
behaving the above way. Try:
complete -r
Upvotes: 0