How to change font size and font for all profiles in terminal?

So I have many profiles in my terminal preference, as shown below

profile

I would like to be able to change the font for all of these different profiles at once

3024 Day, 3024 Night, AdventureTime...

Right now I have to make such change one by one, how do I change the font once and for all?

Please let me know if it is not clear enough of what I am trying to do. Thanks in advance!


Solution 1:

Very easy with an AppleScript code (here an example where all profiles are set to Menlo Regular 18 pt, note that "Menlo Regular" is named "Menlo-Regular" in font name):

tell application "Terminal"
    set ProfilesNames to name of every settings set
    repeat with ProfileName in ProfilesNames
        set font name of settings set ProfileName to "Menlo-Regular"
        set font size of settings set ProfileName to 18
    end repeat
end tell

Solution 2:

I think this will work, but you might need to test it. I'd say you need to be comfortable with the Terminal, but given the question, I'll skip right over it.

Terminal configuration is stored in a property list file in ~/Library/Preferences/com.apple.Terminal.plist in a binary format.

Each profile is stored in a dictionary, and has a Font key within it. You want to extract the Font key from a good profile, and copy/paste into all the others. Or, find/replace if you're using an editor with a regex replace. For example, for the Basic profile, I have:

    <dict>
    <key>Basic</key>
    <dict>
        <key>Font</key>
        <data>
        YnBsaXN0MDDUAQIDBAUGGBlYJHZlcnNpb25YJG9iamVjdHNZJGFy
        Y2hpdmVyVCR0b3ASAAGGoKQHCBESVSRudWxs1AkKCwwNDg8QVk5T
        U2l6ZVhOU2ZGbGFnc1ZOU05hbWVWJGNsYXNzI0AmAAAAAAAAEBCA
        AoADXlNGTW9uby1SZWd1bGFy0hMUFRZaJGNsYXNzbmFtZVgkY2xh
        c3Nlc1ZOU0ZvbnSiFRdYTlNPYmplY3RfEA9OU0tleWVkQXJjaGl2
        ZXLRGhtUcm9vdIABCBEaIy0yNzxCS1JbYmlydHZ4h4yXoKeqs8XI
        zQAAAAAAAAEBAAAAAAAAABwAAAAAAAAAAAAAAAAAAADP
        </data>
        <key>FontAntialias</key>
        <true/>
        <key>FontWidthSpacing</key>
        <real>1.004032258064516</real>
        <key>ProfileCurrentVersion</key>
        <real>2.0600000000000001</real>
        <key>name</key>
        <string>Basic</string>
        <key>type</key>
        <string>Window Settings</string>
    </dict>

You want to copy the whole Font key and data blocks between each of your profiles.

Steps:

  1. Close Terminal.

  2. Back up your original prefs:

    cp ~/Library/Preferences/com.apple.Terminal.plist ~/Desktop/com.apple.Terminal.plist.bak
    
  3. Convert your working copy to XML:

    cd ~/Library/Preferences
    plutil -convert xml1 com.apple.Terminal.plist
    
  4. Edit the file and copy/paste the font data blocks into all the profiles. I used TextMate, but any text edit will work.

  5. Save it, and convert it back to binary:

    plutil -convert binary1 com.apple.Terminal.plist
    
  6. Test Terminal.

The Font block controls the font choice and size. If you also want to replicate colours and text options (antialias, etc), then you'll need to copy/paste those blocks across too.