pbpaste

Hello,
When I paste the contents of the clipboard to the command line via pbpaste, there is also a carriage return implicitly pasted (i.e. whatever gets pasted is automatically sent as a command). Is there a way to use pbpaste without this feature, so I can edit the text before sending the command?

Thanks!

I can't reproduce your problem.

Can you give some details about what you put into the clipboard, and how?

Did you simply type pbpaste at the command line? Which command did you use, exactly?

Thanks.

Highlight: echo hello
Command-C to copy
In OS X, type pbpaste and enter:

bash-3.2$ pbpaste
echo hellobash-3.2$

That didn't execute the command. It pasted it.

$ ll
total 0
drwxr-xr-x   2 scott  staff    68 Jan 15 21:20 .
drwxr-xr-x+ 58 scott  staff  1972 Jan 15 21:20 ..
$ touch x
$ ll
total 0
drwxr-xr-x   3 scott  staff   102 Jan 15 21:20 .
drwxr-xr-x+ 58 scott  staff  1972 Jan 15 21:20 ..
-rw-r--r--   1 scott  staff     0 Jan 15 21:20 x
$ # I put "rm x" in the clipboard at this point
$ 
$ pbpaste
rm x$ ll
total 0
drwxr-xr-x   3 scott  staff   102 Jan 15 21:20 .
drwxr-xr-x+ 58 scott  staff  1972 Jan 15 21:20 ..
-rw-r--r--   1 scott  staff     0 Jan 15 21:20 x

You're right. Once it is pasted, a new prompt appears immediately to the right of the paste, and the pasted text cannot be edited to launch as a command. Do you know if there is a way to do this?

A way to do what? Execute the commands (the thing you thought was happening, but wasn't, you now want to happen)?

pbpaste | sh

That will fail if your "clipboard" has aliases, functions or undeclared variables, etc.

Safer would be to write the output of "pbpaste" to a file, and execute that.

Exactly what I needed... thanks!