title: Mac OS X Safari 6 default search engine change between possible values
body: <p>I would like to change the Safari default search engine programmatically on Mac OS X. I know there are 3 possible values, but where Safari stores the current value? I would like to change from Google to Yahoo from Cocoa code. Is it possible?  </p>
  
  <p>I've seen in the a <code>SearchProviderIdentifierMigratedToSystemPreference</code> variable is set to YES in the <code>com.apple.Safari.plist</code> file, that can be located at <code>~/Library/Preferences</code>. This could be the key to the current value, but where the "System Preference" is stored? Do you have any clues about this?</p>
  
  <hr>
  
  <p>Update: I've found the this command <code>defaults read -g NSPreferredWebServices</code> always returns the selected default search engine. The problem with this is that when I change the value of it, the safari doesn't changes the value.<br>
  Here's the command that changes the value to Bing:<br>
  <code>defaults write -g NSPreferredWebServices '{NSWebServicesProviderWebSearch = { NSDefaultDisplayName = Bing; NSProviderIdentifier = "com.bing.www"; }; }';</code>  </p>
  
  <p>This command should be executed in the terminal.</p>