Sharing the clipboard between accounts

8 February 2013, 01:00

Some people have more than one user account on their Macs. I sometimes do DTP work, for example, so have a separate user account in which is installed lots of fonts.*

Sharing files between accounts is easy — I just save them in the /Users/Shared folder.

Sharing clipboards is trickier. Sometimes I might find a URL in one account that I want to pass through to the other. Cutting and pasting won’t work because each account has its own pasteboard. I could save the URL as a file in /Users/Shared, but it’s a bit clumsy.

Instead, I can use a command-line tool called write. Here’s how it might work if I want to share a URL.

1. I leave open a Terminal window in both accounts. Terminal can be found in the Utilities folder of the Applications list within Finder.

2. In the main account named keir, where I’ve stumbled across the URL, I copy it to the pasteboard in the usual way (that is, highlight it and hit Cmd+C). In the Terminal window I then type the following:

pbpaste|write dtp

… where dtp is the other account’s short name. (To see the short names of currently logged in users, just type users at the prompt.)

3. If I switch to the dtp account, I’ll find the text waiting there for me in the Terminal window. I can then copy and paste it into the URL field of Safari.

At the end of the URL or text that you’ve pasted will be EOF. This stands for End of File, and is Unix’s equivalent of a full stop. You can ignore it.

Instead of the command above, I could simply type write dtp, and then type or paste what I want straight into the Terminal window. When I’ve finished, I’d hit Ctrl+D to send an EOF message. That’s the point at which it will be sent to the other user’s Terminal window.

* Too many fonts installed in a user account (as in hundreds if not thousands) can cause apps like Microsoft Word to take a very long time to start. This is why I run two accounts — one full of fonts needed for DTP work, and one with little more than the standard compliment of OS X fonts.

Know better? Tell me what you think...