TIL: Where iTerm2 stores its ANSI colors

I wanted to review my iTerm2 color scheme from the command line instead of squinting at swatches in the settings UI. The colors live in the prefs plist, under the New Bookmarks array — one dict per profile:

~/Library/Preferences/com.googlecode.iterm2.plist

Each color is a dict of float components (0–1), not hex. The ANSI slots are Ansi 0 Color … Ansi 15 Color (0–7 normal, 8–15 bright), plus Background Color and Foreground Color.

plutil -convert json choked on the file, so I read it with Python’s plistlib, which parses the binary plist directly:

import plistlib

with open("/Users/me/Library/Preferences/com.googlecode.iterm2.plist", "rb") as f:
    prefs = plistlib.load(f)

def hx(c):
    return "#%02X%02X%02X" % tuple(
        round(c[k] * 255) for k in ("Red Component", "Green Component", "Blue Component")
    )

for p in prefs["New Bookmarks"]:
    print(p["Name"], hx(p["Ansi 1 Color"]))  # red

The gotcha: my profile named Dark reported a white background. iTerm2 can keep separate color sets for macOS light vs dark mode — when Use Separate Colors for Light and Dark Mode is on, the live colors sit under (Dark) / (Light)-suffixed keys (Ansi 1 Color (Dark), Background Color (Dark), …) and the unsuffixed keys are stale. Read the suffixed ones or you’ll review the wrong palette.

For reference, here’s what came out — my actual scheme. It’s Monokai Pro with one change: Monokai Pro puts a lavender purple (#AB9DF2) in the magenta slot, which reads too close to blue for me, so I swapped it for a truer magenta.

normalbright
Background#181C23
Foreground#FFFFFF
Black#080200#6F6B68
Red#FF6188#DE6C88
Green#A9DC76#A1C57D
Yellow#FFD866#CAB168
Blue#288AD6#278AD6
Magenta#D089E2#B081C2
Cyan#78DCE8#78BDC6
White#E7E7E7#FFFFFF

(My bright variants are intentionally a touch dimmer than the normals — that’s deliberate, not a typo.)


Let's stay connected!

If you like the post, subscribe to my newsletter to get latest updates:

Author

I'm Oliver Nguyen. A software maker working mostly in Go and JavaScript. I enjoy learning and seeing a better version of myself each day. Occasionally spin off new open source projects. Share knowledge and thoughts during my journey.