From d6312c9c0f9e92cae3219514720736703ec52daf Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Tue, 21 Aug 2018 21:29:38 -0600 Subject: [PATCH] shell2color utility to convert unix shell terminal color schemes to go --- shell2color/shell2color.go | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 shell2color/shell2color.go diff --git a/shell2color/shell2color.go b/shell2color/shell2color.go new file mode 100644 index 0000000..71c5cbe --- /dev/null +++ b/shell2color/shell2color.go @@ -0,0 +1,46 @@ +package main + +import ( + "bufio" + "fmt" + "log" + "strings" +) + +func main() { + in := `$base03: #002b36; +$base02: #073642; +$base01: #586e75; +$base00: #657b83; +$base0: #839496; +$base1: #93a1a1; +$base2: #eee8d5; +$base3: #fdf6e3; +$yellow: #b58900; +$orange: #cb4b16; +$red: #dc322f; +$magenta: #d33682; +$violet: #6c71c4; +$blue: #268bd2; +$cyan: #2aa198; +$green: #859900; +` + + s := bufio.NewScanner(strings.NewReader(in)) + + fmt.Println("{\"Solarized\", []Color{") + + for s.Scan() { + + line := s.Text() + split := strings.Split(line, "#") + color := split[1][:6] + + fmt.Printf("Color{Color: color.RGBA{0x%s, 0x%s, 0x%s, 0xff}},\n", color[0:2], color[2:4], color[4:6]) + } + if err := s.Err(); err != nil { + log.Fatalf("error scanning colors: %v", err) + } + fmt.Println("}},") + +}