Useful macOS defaults: Safari

com.apple.Safari controls how Safari looks and behaves. Many of these settings are not in the Safari Settings window and can only be changed through the command line.

After changing these, quit and reopen Safari.

Developer menu

Show the Develop menu in the menu bar:

defaults write com.apple.Safari IncludeDevelopMenu -bool true

This gives you access to the Web Inspector, the JavaScript console, the responsive design mode, and other developer tools.

Enable the Web Inspector in all web views across macOS (not just Safari):

defaults write NSGlobalDomain WebKitDeveloperExtras -bool true

Debug menu

Show the hidden Debug menu:

defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

This adds an extra menu with tools for testing and troubleshooting Safari.

Show the full URL in the address bar instead of just the domain name:

defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true

Set the default search engine. The values are not the engine names but internal codes. It is easier to change this in Safari Settings.

Tab behaviour

Open new tabs and windows with an empty page instead of your homepage or favourites:

defaults write com.apple.Safari NewTabBehavior -int 1
defaults write com.apple.Safari NewWindowBehavior -int 1

Values:

Press Tab to highlight each item on a web page

By default, pressing Tab in Safari moves between text fields and dropdowns only. To make Tab step through all links and buttons too:

defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true

Privacy and tracking

Block all cookies:

defaults write com.apple.Safari BlockStoragePolicy -int 2

Values:

Send a "Do Not Track" header with every request:

defaults write com.apple.Safari SendDoNotTrackHTTPHeader -bool true

Turn off Safari Suggestions in the address bar (stops queries being sent to Apple):

defaults write com.apple.Safari UniversalSearchEnabled -bool false
defaults write com.apple.Safari SuppressSearchSuggestions -bool true

Turn off preloading the top search result in the background:

defaults write com.apple.Safari PreloadTopHit -bool false

AutoFill

Turn off AutoFill for different types of data:

defaults write com.apple.Safari AutoFillFromAddressBook -bool false
defaults write com.apple.Safari AutoFillPasswords -bool false
defaults write com.apple.Safari AutoFillCreditCardData -bool false
defaults write com.apple.Safari AutoFillMiscellaneousForms -bool false

Warnings

Turn off the warning when visiting a website that is possibly fraudulent:

defaults write com.apple.Safari WarnAboutFraudulentWebsites -bool false

Only turn this off if you have a good reason. It protects you from phishing sites.

Plugins and JavaScript

Allow JavaScript (on by default):

defaults write com.apple.Safari WebKitJavaScriptEnabled -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptEnabled -bool true

Block pop-up windows:

defaults write com.apple.Safari WebKitJavaScriptCanOpenWindowsAutomatically -bool false
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptCanOpenWindowsAutomatically -bool false

Downloads

Set the download location:

defaults write com.apple.Safari DownloadsPath -string "~/Downloads"

Open "safe" files after downloading (like PDFs and images). To stop this:

defaults write com.apple.Safari AutoOpenSafeDownloads -bool false

Remove download list items. Options are after downloading successfully, manually, or after one day:

defaults write com.apple.Safari DownloadsClearingPolicy -int 2

Values:

Status bar

Show the status bar at the bottom of the window (shows link URLs when you hover):

defaults write com.apple.Safari ShowOverlayStatusBar -bool true

Favicons in tabs

Show website icons in tabs:

defaults write com.apple.Safari ShowIconsInTabs -bool true

Backspace to go back

Let the Delete key go back to the previous page:

defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true

Compact tab layout

Use the compact tab bar (address bar merged with tabs):

defaults write com.apple.Safari ShowStandaloneTabBar -bool false

Use the separate tab bar (address bar on its own line):

defaults write com.apple.Safari ShowStandaloneTabBar -bool true

Clear browsing data

You can clear browsing history from the command line, though this is less common as a default:

# Clear history (use with care)
defaults delete com.apple.Safari RecentSearchStrings

Read all current Safari settings

defaults read com.apple.Safari

The output is long. You can filter it:

defaults read com.apple.Safari | grep -i "search"

Notes

Some Safari settings need two keys because Safari uses two web rendering paths (the older WebKit preferences and the newer WebKit2 preferences). When you see both WebKit and WebKit2 versions of a setting, set both to be safe.

Safari is sandboxed, so some defaults may not take effect until you quit and reopen it. If a setting does not seem to work, try logging out and back in.


Enjoyed this post?

Well, you could share the post with others, follow me with RSS Feeds and/or send me a comment via email.


Tags

Category:

Year: