3

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!

4

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
  • Your answer has been really helpful. But how did you find out the correct names of the key words? I am asking this because I want to change the cursor to vertical bar for all themes. Thanks! – zyy Apr 11 at 1:48
  • 1
    @zyy In the Script Editor app, go to the menu File > Open Dictionary, and choose the Terminal app in the list. In the "Terminal Suite" you will see the command "setting set" and here the properties you can change. Unfortunately, there is nothing for choose between Block cursor and Vertical Bar cursor. In these case, the other solution is to use GUI scripting with AppleScript, in order to simulate clicks on check box and buttons of the interface. Or open the preference file .plist from Alex answer, and search or add the key CursorType for all dict entry, and set <integer>2</integer>. – quark67 Apr 11 at 2:35
1

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.

  • I made some edits; however, the order of your steps is wrong. If your first close Terminal, then how are you going to run the commands in the other steps! Also, you only need to use 1. for each step and they'll auto number correctly, which makes it easier to move/add/remove the steps when edits are needed. – user3439894 Feb 25 at 4:27
  • Ah, good point. I actually use iTerm2, this was the first time firing up Terminal in a while, and during testing I noticed that on save it writes back the prefs. Regardless, goal is easily accomplished with the steps provided. – Alex Feb 25 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .