Is there an actual file where the data is stored while I have something in my clipboard?
Pasteboard is handled by
pbs process on OS X. Things which are copied are stored inside
pbs address space. More about that is on Apple Pasteboard Server article.
Whether the data is transferred between objects in the same application or two different applications, in a Cocoa application the interface is the same—an NSPasteboard object accesses a shared repository where writers and readers meet to exchange data. The writer, referred to as the pasteboard owner, deposits data on a pasteboard instance and moves on. The reader then accesses the pasteboard asynchronously, at some unspecified point in the future. By that time, the writer object may not even exist anymore. For example, a user may have closed the source document or quit the application.
Consequently, when moving data between two different applications, and therefore two different address spaces, a third memory space gets involved so the data persists even in the absence of the source. NSPasteboard provides access to a third address space—a pasteboard server process (pbs)—that is always running in the background. The pasteboard server maintains an arbitrary number of individual pasteboards to distinguish among several concurrent data transfers.
As Mateusz pointed out, there's no file with this information. However, you can use
pbpaste to manipulate the pasteboard.
ls | pbcopy will copy the output (stdout) of
ls to the pasteboard.
The pasteboard server process is
pbs, and you can verify that by checking the man pages for both.
Now that we know the correct process we can:
- load up Activity Monitor
- search for the
- get info using cmd+i
- view Open Files and Ports
We can see that the only files it has open are itself, dyld and the dyld cache.