In bash I set a variable like:
o='OneDrive - MyCompany'. Then I use itby typing:
cd "$o"/Docu. Then I press TAB to do word completion on the folder name. The result is
cd $o/Documents. I hit enter and it fails because it stole my double quotes. HUH!?! I want to use
"$o" as a very fast shortcut for that directory name. I don't want to type
"$o/Docu and then press TAB and then
", which works. When I start typing I don't want to think about whether I might press TAB to expand something later in the path. I just want to follow the rule to double quote variables, but that doesn't work here.
I really want to be able to put backslashes before the spaces when defining the variable and have them be respected after expanding it. Is there any way I can do that? It would solve this problem so nicely.
What is the best way to deal with this? I don't want to fight the system, but I do want something that feels fast and natural.
Are there any shell settings that I should change to get closer to the expected behavior? I used tcsh for 25 years and am just now switching to bash. There's a lot to learn and tweak. My current shell options are:
Note: This question is different from Why can't I use tab expansion/auto-complete of shell variables with cd? but turns out it has the same answer.