If I drop a file from Finder (or another file source) into the Terminal, the system helpfully escapes characters like spaces: Dropping a file named /Lorem Ipsum.txt
yields /Lorem\ Ipsum.txt
.
I would like to change this behavior to use quotation marks instead, so that /Lorem Ipsum.txt
would yield '/Lorem Ipsum.txt'
instead (note the single quotation marks and the missing backslash).
Is there a way to do this using the standard Terminal.app? If not, is it maybe possible with iTerm or something else?
Edit
The reason why I want to do this is that I am using xonsh that parses the backslash as a literal character, echo /Lorem\ Ipsum.txt
prints /Lorem\ Ipsum.txt.
Most of the time I will just manually delete the backslashes, and sometimes I use the following workaround:
- Enter
@(r"
- Drop the file – this will fill a string literal with the path using backslash-escapes
- Enter
".replace("\\",""))
quote
with the contentecho "'$@'"
to do the conversion./Lorem` and
Ipsum.txt`, but you are right, I could create a script that does the conversion.