|
|
Paste in Terminal: Avoid Line Breaks?
|
|
|
|
Mac Elite
Join Date: Jan 2004
Location: Berkeley, CA
Status:
Offline
|
|
I'm having trouble copying and pasting from TextEdit into the Terminal. When my text has line breaks, Terminal sends the command after each line break, instead of copying the whole chunk of text and waiting for me to press enter. What setting can I change, or what button can I press, to avoid this?
|
"Give me a lever long enough and a fulcrum on which to place it, and I shall move the world." -Archimedes
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: Nov 2000
Location: in front of my Mac
Status:
Offline
|
|
Insert a \ before every line break.
|
•
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2004
Location: Berkeley, CA
Status:
Offline
|
|
That defeats the whole purpose of copy/pasting, doesn't it? Anything more automatic?
|
"Give me a lever long enough and a fulcrum on which to place it, and I shall move the world." -Archimedes
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jan 2002
Location: London
Status:
Offline
|
|
Well, there's Edit > Paste Escaped Text, which will escape the carriage returns for you. But it will also escape all special characters, including spaces. So it's likely this won't achieve what you want.
Terminal.app doesn't have an 'only escape carriage returns' option, unfortunately.
In TextEdit, you could do a Find to automatically replace all the "CR"s with "\CR". Put your cursor in the "Find" box, and type "Cmd-A Opt-Return" to select everything and replace it with a carriage return. Then put your cursor in the "Replace with" box and type "Cmd-A \ Opt-Return". Once you've added backslashes to the end of each line, you should be able to copy and paste into Terminal as desired.
The problem with Terminal.app is that it's just talking to a standard UNIX terminal, which doesn't natively understand 'text' as an object to be pasted in and out like the rest of OS X does. When you paste text into Terminal.app, it converts it into a string of characters (including carriage returns), and then virtually types it into the terminal as if you'd typed them yourself. This is why pasting even works when you're connected to an esoteric remote terminal. But it means that if you want something escaped when you paste it in, you have to tell it specifically.
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status:
Offline
|
|
What about a Service (or widget) that strips new lines? Select the text, choose the service, copy paste? Something like this must exist right?
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Mar 2004
Status:
Offline
|
|
Originally Posted by tavilach
I'm having trouble copying and pasting from TextEdit into the Terminal. When my text has line breaks, Terminal sends the command after each line break, instead of copying the whole chunk of text and waiting for me to press enter.
Mine doesn't do that... long lines work fine, both with and without \ line continuation chars.
Perhaps you should tell us your OS version and shell. (I use bash 2.05b.0 under Tiger 10.4.8)
--
Actually, now that I re-read chrismear's post... he's got a point: the shell will react to some chars
in certain ways. It does NOT like ascii $'\015' (not even if you add it the the definition for $IFS).
Another example: if the ~/.bashrc file is used to bind '"\t":menu-complete' then, pasting a bunch
of text that contains any tab chars will produce unpredictable results... as the shell takes the tab
and "completes" it in whatever way works at the moment.
I offer 2 solutions: 1) learn how to write shell scripts, and 2) try TextWrangler. TextWrangler has
a pretty cool feature set... and it allows you to build -- and run -- a script in a "text" document.
(
Last edited by Hal Itosis; Nov 11, 2006 at 07:23 PM.
)
|
-HI-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|