While testing a new machine setup today, I noticed that Safari wasn’t opening to the default homepage like it should. Instead, it was opening Safari’s Top Sites.
There wasn’t an obvious way to set the Safari new window setting from the command line, but with the assistance of Greg Neagle, I’ve mapped out the applicable keys and their settings. See below the jump for the details.
The behavior of new Safari windows is set by the NewWindowBehavior key in /Users/username/Library/Preferences/com.apple.Safari.plist. Likewise, new Safari tabs are set by the NewTabBehavior key in /Users/username/Library/Preferences/com.apple.Safari.plist.
Both keys use an integer to set the desired behavior. Here’s how it maps out:
com.apple.Safari NewWindowBehavior
com.apple.Safari NewWindowBehavior 0 = Homepage
com.apple.Safari NewWindowBehavior 1 = Empty Page
com.apple.Safari NewWindowBehavior 2 = Same Page
com.apple.Safari NewWindowBehavior 3 = Bookmarks
com.apple.Safari NewWindowBehavior 4 = Top Sites
com.apple.Safari NewTabBehavior
com.apple.Safari NewTabBehavior 0 = Homepage
com.apple.Safari NewTabBehavior 1 = Empty Page
com.apple.Safari NewTabBehavior 2 = Same Page
com.apple.Safari NewTabBehavior 3 = Bookmarks
com.apple.Safari NewTabBehavior 4 = Top Sites
Here’s the defaults commands to set the NewWindowBehavior and NewTabBehavior keys to the various available settings:
Set new Safari windows to open to Safari’s default homepage:
defaults write com.apple.Safari NewWindowBehavior -int 0
Set new Safari windows to open to an empty page:
defaults write com.apple.Safari NewWindowBehavior -int 1
Set new Safari windows to open to the same site as the last-opened page:
defaults write com.apple.Safari NewWindowBehavior -int 2
Set new Safari windows to open the Safari bookmarks page:
defaults write com.apple.Safari NewWindowBehavior -int 3
Set new Safari windows to open the Safari Top Sites page:
defaults write com.apple.Safari NewWindowBehavior -int 4
Set new Safari tabs to open to Safari’s default homepage:
defaults write com.apple.Safari NewTabBehavior -int 0
Set new Safari tabs to open to an empty page:
defaults write com.apple.Safari NewTabBehavior -int 1
Set new Safari tabs to open to the same site as the last-opened page:
defaults write com.apple.Safari NewTabBehavior -int 2
Set new Safari tabs to open the Safari bookmarks page:
defaults write com.apple.Safari NewTabBehavior -int 3
Set new Safari windows to open the Safari Top Sites page:
defaults write com.apple.Safari NewTabBehavior -int 4