is there a way to copy a string to clipboard from command line?
To be more specific, I want to make a script which copies my email address to clipboard, so that when I need to insert it several times for logging in / register, I just run the script once and then CMD+V it whenever I need.
I heard of pbcopy
, but I think this is not my case. Any suggestion?
Many thanks!
To copy something on Mac, select it and press Command + C . This copies your data or item to clipboard, and you can paste it where you need it. Use Command + V to paste. If you want to remove a piece of text or a file as you are copying it, simply swap out the Command + V for Command + X .
I could have opened another text editor and then copy and pasted the lines but this is so inconvienient. In Mac OS X you can use a command called pbcopy for situations like these. Now the output given by the cat command got transfered into the clipboard and can be pasted wherever you want it.
You can copy and paste text from other documents into a Terminal window. Note: If the text being pasted includes the return character at the end of a line, the command is executed immediately. In the Terminal app on your Mac, do any of the following: Copy text in another app, and then in Terminal choose Edit > Paste.
You need to pipe the output of your script to pbcopy
For example:
./somescript.sh | pbcopy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With