I'm interested in moving color values I've created for OS X Terminal to applications on other platforms, such as Linux. I'm familiar with the usual methods of representing color values like RGB, HSB, L*A*B, HEX, etc. However, the <data>
strings used in Terminal settings files are unlike other methods used to define colors. I'd like help understanding this XML <data>
type in relation to other color values.
As an example, I used OS X's built-in Color Picker to manually change Terminal's default ANSI scheme with HSB values from Ethan Schoonover's excellent Solarized. I then saved those settings in an XML .plist called Solarized Dark xterm-256color.terminal
(The contents of that file may be found here.)
I arbitrarily chose brblack
from that file as a single color value for comparison:
<key>ANSIBrightBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NOMCAw
LjE2NDUgMC4yMQAQAoAC0hAREhNaJGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIU
WE5TT2JqZWN0XxAPTlNLZXllZEFyY2hpdmVy0RcYVHJvb3SAAQgRGiMtMjc7QUhOW2Jx
c3V6hY6WmaK0t7wAAAAAAAABAQAAAAAAAAAZAAAAAAAAAAAAAAAAAAAAvg==
</data>
This looks much different (and more complex) than the simple HSB value 193 100 21
taken from Schoonover's table:
SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B RGB HSB
--------- ------- ---- ------- ----------- ---------- ----------- -----------
base03 #002b36 8/4 brblack 234 #1c1c1c 15 -12 -12 0 43 54 193 100 21
...
Why does the simple value 193 100 21
get converted into a data string 5 lines long? What other information is contained in that string? Finally, and most importantly, how can I convert such a string into simple standard color values that I can use on other platforms?
Best Answer
bplist
means binary property list, which can be converted to XML withplutil -convert xml1
. Inside each plist for a color is another data key for the fractional RGB values./usr/libexec/PlistBuddy -x -c 'Print "Window Settings":"My Theme"' ~/Library/Preferences/com.apple.Terminal.plist|tr -d '\n\t'|grep -o '[^>]*</key><data>[^<]*'|while read l;do echo ${l%%<*} $(base64 -D<<<${l##*>}|plutil -convert xml1 - -o -|awk '/<data>/{getline;print}'|tr -d '\t'|base64 -D);done
The output looks like this: