cat your.itermcolors | plist2json | bb -i -o -f convert.clj
Last active
April 11, 2020 06:44
-
-
Save rebeccajae/9d73f383d465c66f046119cf08aaa886 to your computer and use it in GitHub Desktop.
take a jsonified iterm color scheme and convert it to a binja colors table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def iterm-color-name-mapping | |
(apply hash-map | |
["ANSI_0_COLOR" "BLACK" | |
"ANSI_1_COLOR" "RED" | |
"ANSI_2_COLOR" "GREEN" | |
"ANSI_3_COLOR" "YELLOW" | |
"ANSI_4_COLOR" "BLUE" | |
"ANSI_5_COLOR" "MAGENTA" | |
"ANSI_6_COLOR" "CYAN" | |
"ANSI_7_COLOR" "WHITE" | |
"ANSI_8_COLOR" "BRIGHT_BLACK" | |
"ANSI_9_COLOR" "BRIGHT_RED" | |
"ANSI_10_COLOR" "BRIGHT_GREEN" | |
"ANSI_11_COLOR" "BRIGHT_YELLOW" | |
"ANSI_12_COLOR" "BRIGHT_BLUE" | |
"ANSI_13_COLOR" "BRIGHT_MAGENTA" | |
"ANSI_14_COLOR" "BRIGHT_CYAN" | |
"ANSI_15_COLOR" "BRIGHT_WHITE"])) | |
(defn format-text [s] | |
(str/upper-case | |
(str/replace | |
s #"\s" "_"))) | |
(defn scale-to [v m] | |
(int (Math/floor (* v m)))) | |
(defn color-spec-to-binja [plist-color-spec] | |
(let [candkey (format-text (key plist-color-spec)) | |
r (scale-to (get (val plist-color-spec) "Red Component") 255) | |
g (scale-to (get (val plist-color-spec) "Green Component") 255) | |
b (scale-to (get (val plist-color-spec) "Blue Component") 255)] | |
(hash-map (get iterm-color-name-mapping candkey candkey) | |
(vector r g b)))) | |
(defn iterm-to-binja [iterm-val] | |
(hash-map "colors" | |
(apply merge | |
(map color-spec-to-binja iterm-val)))) | |
(json/generate-string | |
(iterm-to-binja | |
(json/parse-string | |
(first *input*))) {:pretty true}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment