pbpaste


 
Thread Tools Search this Thread
Operating Systems OS X (Apple) pbpaste
# 1  
Old 01-15-2012
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!
# 2  
Old 01-15-2012
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.
# 3  
Old 01-15-2012
Highlight: echo hello
Command-C to copy
In OS X, type pbpaste and enter:

bash-3.2$ pbpaste
echo hellobash-3.2$
# 4  
Old 01-15-2012
That didn't execute the command. It pasted it.

Code:
$ 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

# 5  
Old 01-15-2012
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?
# 6  
Old 01-15-2012
A way to do what? Execute the commands (the thing you thought was happening, but wasn't, you now want to happen)?

Code:
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.
This User Gave Thanks to Scott For This Post:
# 7  
Old 01-15-2012
Exactly what I needed... thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. OS X (Apple)

Piping to grep with pbpaste

cat file 1 aaa 2 bbb 3 ccc 4 ddd In TextEdit, I then copy the characters “ccc” to the clipboard. The problem is that the following command gives no output: bash-3.2$ pbpaste | grep - file Desired output: 3 ccc What should the syntax be for that command? I am using MacOS El... (3 Replies)
Discussion started by: palex
3 Replies

2. UNIX for Dummies Questions & Answers

pbpaste to application in terminal

Is it possible to execute a pbpaste command to an application or current application in focus? Thanks (0 Replies)
Discussion started by: fhill2
0 Replies

3. Shell Programming and Scripting

pbpaste and grep with Mac X11

Hello, Here is what I am trying to do: 1) Copy a string to the pasteboard using Command-C 2) Search for the string in a file in X11. Command-C pbaste | grep - filname (does NOT work) What is the correct syntax? Thanks! (4 Replies)
Discussion started by: palex
4 Replies
Login or Register to Ask a Question