I tab a lot between tasks and would like to make sure that I do not accidentally paste something where it does not belong. Thus, is there a feature or an app that allows me to auto-clear my clipboard after n seconds or after having pasted n times?
2 Answers
The script below clears the clipboard every S seconds:
#!/bin/sh
# pbclear [seconds]
S=${1:-10}
while true
do
pbcopy < /dev/null
sleep $S
done
Save it to a file named pbclear
, set executable permissions with chmod +x pbclear
, and put it somewhere in your path, for instance, /usr/local/bin
. Then run it in the background with pbclear 60 &
to clear the clipboard every 60 seconds.
set the clipboard to ""
or from the Command Line,printf "" | pbcopy
used in this manner will copy nothing thus overriding the general pasteboard (clipboard). Either can be used in Automator to make an App or Service, the latter of which could have a keyboard shortcut assigned. Or in an AppleScript App you could put in the Dock to click when you'd like, etc.