10

On my MacBook Pro I have found that several applications seem to share the value for a find. For example, I searched 'applestackexchange' in Safari's unified address bar, then I switch to Xcode and click into a Find field. The first word of my search in Safari then appears there. iTerm2 and Sublime Text 2 also seem to participate in this sharing.

Running latest Mountain Lion on a 2012 MBP.

3
  • I noticed that too. It's probably a bug and the reason for that must be that they use the same buffer for the search text. Commented Feb 8, 2013 at 16:32
  • 2
    This is intensely annoying and I really wish there was a way to disable it system-wide.
    – pinhead
    Commented Jan 3, 2020 at 19:30
  • apple.stackexchange.com/questions/440148/… provides an answer specific to iTerm2.
    – Gilby
    Commented May 4, 2022 at 0:15

2 Answers 2

4
+50

macOS utilizes 4 different clipboards: General, Ruler, Font, and Find

General is the main clipboard obviously. From the command line we can copy things to and from the different clipboards. In Terminal.app, you can read all about the pbcopy and pbpaste commands with man pbcopy and man pbpaste

In short, when invoking the Find command in most applications, the text you insert in the Find field automatically gets placed into the Find clipboard. That is why when invoking the Find command in a different application, the Find field is automatically inserted from what is currently in your Find clipboard.

Paste this following AppleScript code into a new Script Editor.app document. Running the code will display a dialogue giving you the option to choose which of the four clipboards' text or rtf contents you would like to view

property theClipboards : {"general", "find", "font", "ruler"}

activate
set chosenClipboard to item 1 of (choose from list theClipboards ¬
    with title "Choose A Clipboard" with prompt ¬
    "Choose a clipboard to view its contents." OK button name ¬
    "View Chosen Clipboard" cancel button name "Cancel")

set theResult to displayClipboard(chosenClipboard)

activate
display dialog theResult buttons {"OK"} default button 1 ¬
    with title ("Contents of Pasteboard " & chosenClipboard) --giving up after 5

to displayClipboard(chosenClipboard)
    set theResult to (do shell script "pbpaste  -pboard " & chosenClipboard)
end displayClipboard

enter image description here


Running this following command in Terminal will clear out the contents of the Find clipboard. echo "" |pbcopy -pboard find


Possible work-around/solution:

You can create a new Automator Quick Action and add a Run Shell Script command to the workflow and add this following code to the Run Shell Script command.

echo "" |pbcopy -pboard find ;osascript -e 'tell application "System Events" to keystroke "f" using {command down}'

enter image description here

Save your new Automator Quick Action then in System Preferences, assign a keyboard shortcut to the new Automator Quick Action. (I assigned ⌃F to the new keyboard shortcut.)

enter image description here

Now instead of invoking Find with ⌘F, the new ⌃F shortcut will clear the contents of the Find clipboard then opens the Find search field with nothing already in there from any previous searches.

It's not a perfect solution but it may help.

4
  • Thanks for the informative explanations! Commented May 3, 2022 at 22:06
  • brilliant! any way to disable the behavior of sharing the Find clipboard across all apps? apple.stackexchange.com/q/315423/3553
    – iconoclast
    Commented May 5, 2022 at 1:30
  • @iconoclast I added a possible solution to my post.
    – wch1zpink
    Commented May 5, 2022 at 14:30
  • very interesting! but (if I understand it correctly) it does nothing to preserve the previous contents of application B's field field after I enter something in application A's find field, right?
    – iconoclast
    Commented May 6, 2022 at 4:05
2

I've found it. It's called FindScrap.

At the command line, enter:

defaults write <program> FindDialog_UsesFindScrap -bool NO

Where <program> is something like com.barebones.bbedit.

(source: https://www.barebones.com/support/bbedit/ExpertPreferences.html#texts, accessed 20180203)

If the application you use doesn’t support this, you may have to open a request that it be implemented there as well. Developers can choose how to I ple,ent clipboard manage,ent and automation by using Apple SDK and API or inventing their own code to manage this so it may not be “cookie cutter” how to enable this globally.

5
  • What reason do you have to believe this will work for programs other than BBEdit?
    – iconoclast
    Commented Feb 16, 2018 at 1:29
  • First, because it has actually affected all the applications where I observed it. (These were listed in my original, detailed statement of the problem, at apple.stackexchange.com/questions/314359/…) Second, because it's a setting at the level of the operating system, and only <program> is specific to BBEdit Commented Feb 17, 2018 at 13:39
  • in what other applications have you observed this defaults write line working? I'd be very surprised if the FindDialog_UsesFindScrap key was not defined by the BBEdit folks.
    – iconoclast
    Commented Feb 19, 2018 at 3:32
  • Any way to turn this off universally?
    – jcm
    Commented Jul 17, 2018 at 12:13
  • Let me state the problem more strongly: the FindDialog_UsesFindScrap is defined by the BBEdit folks. It is not an OS setting, even if BBEdit is using some Apple-provided framework to sync the find field values. This is a setting used by BBEdit, and therefore the idea that it will work for other apps has been given absolutely no evidence whatsoever. If you know of other apps where your defaults write line works, please provide them.
    – iconoclast
    Commented Jul 17, 2018 at 19:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .