Copy a string to clipboard from Mac OS command line

老子叫甜甜 提交于 2020-01-01 04:42:15

问题


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!


回答1:


You need to pipe the output of your script to pbcopy

For example:

./somescript.sh | pbcopy



回答2:


echo 'your-email@example.com' | pbcopy (as @Jonathan Leffler stated above)

Or see the answer for the related question on piping to clipboard on different operating systems: Pipe to/from the clipboard



来源:https://stackoverflow.com/questions/39692617/copy-a-string-to-clipboard-from-mac-os-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!