Copy a string to clipboard from Mac OS command lin

2020-06-12 03:14发布

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!

2条回答
来,给爷笑一个
2楼-- · 2020-06-12 03:34

You need to pipe the output of your script to pbcopy

For example:

./somescript.sh | pbcopy
查看更多
Juvenile、少年°
3楼-- · 2020-06-12 03:35

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

查看更多
登录 后发表回答