macos-terminal-themes icon indicating copy to clipboard operation
macos-terminal-themes copied to clipboard

General question: Format of a theme file / color

Open assayire opened this issue 1 year ago • 1 comments

I have searched for a quite a while to understand the format of the theme file particularly the color.

For example, how do i parse the color under, say ANSIBlueColor:

<key>ANSIBlueColor</key>
<data>
YnBsaX...
</data>

Looks like the data (color value) is base64 encoded which when I decode gives some binary data. So, how do I parse the binary data to extract the color values for ANSIBlueColor?

Would be a huge help if you can shed some light on this. Thanks 🙏

assayire avatar Nov 08 '23 01:11 assayire

@assayire take a look at tools/iterm2terminal.swift script we wrote a while ago to convert iTerm's *.itermcolors themes into macOS Terminal format.

especially on these lines https://github.com/lysyi3m/macos-terminal-themes/blob/master/tools/iterm2terminal.swift#L84-L90

in short, the answer is: data here is a serialized { color: NSColor } object, which returned by NSKeyedArchiver.archivedData() and the "format" is - if I remember correctly, an Apple's proprietary "binary plist" format.

I'm not sure about solution to decode it using 3rd party tools, but something like NSKeyedUnarchiver.unarchiveObject(...) might work

lysyi3m avatar Nov 08 '23 06:11 lysyi3m