7

Ever since I discovered you can use filename completion in double quotes, I've been using it for files with spaces in their names (like /Library/Application Support). It looks nicer and is easier to read than a path littered with backslashes. The problem is, there are also things in my home folder with spaces in their names (~/Library/Application Support, and I can't use quotes there because they escape tildes. Is there any way to turn that off?

2 Answers 2

5

I don't think so. The zsh user's guide simply says:

Double quotes allow some, but not all, forms of substitution inside. More specifically, they allow parameter expansion, command substitution and arithmetic substitution, but not any of the others: process substitution doesn't happen, braces and initial tildes and equals signs are not expanded and patterns are not special. Here's a table; each expression on the left is some command line argument, and the results show what is substituted if it appears outside quotes, or in double quotes.

Expression      Outside quotes  In double quotes 
------------------------------------------------ 
...  
~/foo           /home/pws/foo   ~/foo
1

Tildes don’t expand in double quotes but you don’t need them too. Place the starting quote after the tilde and it works as you want:

~"/Library/Application Support"
~/"Library/Application Support"

Alternatively, the environment variable HOME expands to the same:

"$HOME/Library/Application Support"
"${HOME}/Library/Application Support"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .