Paste escaped text

by Francois Joseph de Kermadec


The Mac OS X Terminal goes to great lengths to allow its users to easily enter paths to folders and files: by simply dropping the icon of the file onto the Terminal's window, the application will automatically complete its path, all in its escaped form, ready to be used. This classical trick without doubt makes Command Line fans scream in horror but we GUI people find it pretty handy.




Where Terminal isn't helping, I thought, is when it comes to pasting the aforementioned paths — such as when you're reading an article on this very MacDevCenter and want to try something out. The Mac has always worked with weird folder names, containing special characters and spaces: they're a joy to see in the Finder but a pain to use in a pure UNIX environment. This is where the Terminal's edit menu comes to the rescue. Indeed, since the Panther days, it features a "Paste Escaped Test" item, allowing you, with one swell key combination, to enter any path you desire, no matter as complex, all with\ the\ right\ escape\ characters\ in\ place.




What may seem like a minor addition to the Terminal will without doubt save many headaches to those of us who need to work with complex paths on remote servers or proofread written documentation — which, usually, means copying and pasting all the example sessions line-by-line in the Terminal to ensure they work as advertised.




This feature has been here for a while now but I shamefully confess I hadn't noticed it until recently and I thought I should share it with my fellow Mac users who, like me, don't always read the friendly manual.


2 Comments

msporleder
2005-08-29 09:52:41
indeed
This is very helpful, actually. However, if you're in a situation where you can't get intl characters onto the clipboard in a terminal, try the following:


ls -b to get the escape codes for everything, and then use backticked echo -ne to paste it:


cd `echo -ne '\345\244\247'` will get you into the directory with those escapes.


Another fun thing is how ls will actually print intl characters and ls will not.

ediathome
2005-08-30 01:36:13
also quite useful...
is the possibility to simply drag a folder to a terminal window and the full path is being inserted right away.