Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

TextExpander shell script snippet to set Safari 6 default fonts Apps
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:
#!/bin/bash
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:
#!/bin/bash
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.]
    •    
  • Currently 4.00 / 5
  You rated: 5 / 5 (7 votes cast)
 
[9,899 views]  

TextExpander shell script snippet to set Safari 6 default fonts | 3 comments | Create New Account
Click here to return to the 'TextExpander shell script snippet to set Safari 6 default fonts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
TextExpander shell script snippet to set Safari 6 default fonts
Authored by: aaronrp on Aug 01, '12 08:57:10AM

I remember being able to set the default font in Mosaic, back in the day. Hard to believe Apple would take away something so basic.



[ Reply to This | # ]
TextExpander shell script snippet to set Safari 6 default fonts
Authored by: swilcox on Aug 01, '12 02:49:06PM

I'm a real novice at this. If I want to revert back to the default Safari configuration, how do I do that?



[ Reply to This | # ]
TextExpander shell script snippet to set Safari 6 default fonts
Authored by: joelbruner on Aug 03, '12 10:16:08AM
This will delete all the keys the hint adds and set things back the way they were:
defaults delete com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2StandardFontFamily
defaults delete com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DefaultFontSize
defaults delete com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2FixedFontFamily
defaults delete com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DefaultFixedFontSize


[ Reply to This | # ]