TextExpander shell script snippet to set Safari 6 default fonts

Aug 01, '12 07:30:00AM

Contributed by: mcohen

Apple removed the default font settings preferences in Safari 6, but one can easily change them with a set of Terminal commands. More fun, though, is using TextExpander's Shell Script Snippet feature to do it. Slight advantage: once the snippet is in your collection, you can edit the snippet to change the fonts at any time without having to dig up the commands from your memory. Note that you have to quit and restart Safari for the changes to take effect.

Save the following text as a shell script:

defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2StandardFontFamily 'Lucida Grande'
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DefaultFontSize 14
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2FixedFontFamily Consolas
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DefaultFixedFontSize 11
Update: The submitter, Michael Cohen, wrote me saying that his brother Norman Cohen improved on the above script. I'll leave the original there, but below is a newer version, where the script quits and restarts Safari, and using TextExpander's fill-ins, lets you specify the fonts and sizes on the fly:
if [[ $(ps -ax | grep -i safari | grep -v grep | wc -l) -ge 1 ]] ; then osascript -e "tell application \"Safari\" to quit";  fi
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2StandardFontFamily '%filltext:name=font-face:default=Lucida Grande%'
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DefaultFontSize %filltext:name=default-font-size:default=14%
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2FixedFontFamily '%filltext:name=fixed-font-face:default=Consolas%'
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DefaultFixedFontSize %filltext:name=fixed-font-size:default=11%
osascript -e "tell application \"Safari\" to activate"
[kirkmc adds: As mentioned above, you can run each line individually, or change them as you wish to your preferred font and size.]

Comments (3)

Mac OS X Hints