I would like to find a combination of keys to clear the contents of the clipboard or better yet an application that can configure a timer to clear it automatically one minute after last paste operation.
MacOS – n easy way to clear/empty the clipboard
copy/pastemacos
Related Solutions
This isn't quite perfect for what you want, but I think it might get you closer. Quicksilver has a command line tool. When installed, you can pipe files from the command line to Quicksilver app, and from there send them as attachments in Mail.
To install Quicksilver command line tool, activate Quicksilver. Then navigate to Quicksilver > Preferences to open preferences window. Click on Preferences on top right of window. On the left, click on Command Line Tool and install.
In Terminal, you'll be able to type
qs path/to/file1 path/to/file2 path/to/file3 path/to/file4
Pressing enter will send those files to Quicksilver's first pane. Press tab to move to the action pane and choose the Mail/New Email With Attachment action. Press enter, and a new email with your selected files attached should appear.
Note that you will also have to install the Mail and Command Line plugins in Quicksilver (Quicksilver > Preferences > Plug Ins).
Stdout in this case is line-buffered and is 1024 bytes which is causing the output truncation on the display. When you paste from the clipboard the non-printable New-Line (EOL) characters at the end of each line are simply counted as another character on the line as far as the buffer count is concerned. The reason the math doesn’t add up for where the truncation happens that @miken32 was trying to calculate, is because you are not counting the New-Line characters.
If you cat the test file using a –e option you can see the non printable EOL characters as $, including them in the math should add up.
$ cat -e test
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890$
You can get around filling the line buffer with pasted bytes if you specify your own end-of-file (EOF) marker to the cat command. This way when the cat command encounters the EOL characters it will reset the line buffer at the beginning of each new line instead of just counting them as another byte in a continuous stream because the cat command is parsing each new line looking for the EOF string on a line by itself to know when to exit.
You can do something like this :
cat << EOF > test
The stdin redirect (<< EOF) tells cat to keep printing until it encounters input matching the specified end-of-file characters on a new line by themselves. This way stdout will then print every pasted printable character line by line, the drawback is that you get a “>" character in the output at the start of each new line.
$ cat << EOF > test
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890
> EOF
The end-of-file marker is typed literally as the characters E, O, F, after your paste and can be anything you like. Also the EOF characters, and the > characters are not included in the redirected output sent to the file. Typing the letters as EOF is just symbolic and can be anything you like, XXX for example, you just have to be certain that what ever EOF marker you specify does not appear in the paste buffer.
For the record, you can still use ^D as the EOF marker when using stdin, even though you specify something else. The use of the EOF string is an old school scripting convention for delimiting a block of text to redirect from within the script.
Hope this helps.
Related Question
- Way to see the invisible formatting in the clipboard and/or create the formatting when piping to pbcopy
- Paste text with AppleScript without simulating cmd-v with System Events
- MacOS – Clear Clipboard on OS X after ‘n’ seconds
- MacOS – Simplest way to capture “keystroke representation” to clipboard
- Make Ctrl-k in Terminal copy to the system clipboard
- Paste image from the clipboard into a PDF in Preview
- Automator script to paste each word on clipboard followed by tab key
Best Answer
Yes, you have a choice of three built in methods for clearing the clipboard.
AppleScript/Automator are two simple methods for programmatically manipulating the clipboard.
Here's a little script that does what you want.
Also, Automator allows the same. You'll need to define a variable, double click on the name text to set it to null, and then drag in the set clipboard action before running / saving it. The benefit of using automator is that you can assign it as a service and then use system keyboard shortcuts to call it.
For AppleScript or one of the nice terminal answers here that use
pbpaste
you might want to look at a free tool like FastScripts to launch the action from anywhere.