diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index 9c8751c6..741b7d35 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -149,11 +149,11 @@ Text character to use at the end of the segment. Will take the background color ### Foreground -Hex [color][colors] to use as the segment text foreground color. +Hex [color][colors] to use as the segment text foreground color. Also supports transparency using the `transparent` keyword. ### Background -Hex [color][colors] to use as the segment text background color. +Hex [color][colors] to use as the segment text background color. Also supports transparency using the `transparent` keyword. ### Properties @@ -201,6 +201,9 @@ do so like this: "prefix": "<#CB4B16>┏[", ``` +Oh my Posh offers support for hex [colors][colors] as well as the `transparent` keyword to create either a transparent foreground +override or transparent background color using the segement's [foreground][fg] property. + ## Full Sample ```json @@ -296,3 +299,4 @@ do so like this: [nf]: https://www.nerdfonts.com/ [segments]: /docs/battery [colors]: https://htmlcolorcodes.com/color-chart/material-design-color-chart/ +[fg]: /docs/configure#foreground diff --git a/renderer.go b/renderer.go index 52662928..6888dde1 100755 --- a/renderer.go +++ b/renderer.go @@ -91,13 +91,13 @@ func (r *Renderer) writeAndRemoveText(background string, foreground string, text } func (r *Renderer) write(background string, foreground string, text string) { - rex := regexp.MustCompile(`<\s*(?P#[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})>(?P.*?)<\s*/\s*>`) + rex := regexp.MustCompile(`<((#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent))>(.*?)`) match := rex.FindAllStringSubmatch(text, -1) for i := range match { // get the text before the color override and write that first textBeforeColorOverride := strings.Split(text, match[i][0])[0] text = r.writeAndRemoveText(background, foreground, textBeforeColorOverride, textBeforeColorOverride, text) - text = r.writeAndRemoveText(background, match[i][1], match[i][2], match[i][0], text) + text = r.writeAndRemoveText(background, match[i][1], match[i][4], match[i][0], text) } // color the remaining part of text with background and foreground r.writeColoredText(background, foreground, text) diff --git a/themes/aliens.json b/themes/aliens.json index a7a43eca..8002c3da 100644 --- a/themes/aliens.json +++ b/themes/aliens.json @@ -51,8 +51,7 @@ "leading_diamond": "", "trailing_diamond": "", "properties": { - "prefix": "  ", - "prefix": "<#193549> " + "prefix": " " } } ] diff --git a/themes/fish.json b/themes/fish.json index 50be235e..f3d8ed8e 100644 --- a/themes/fish.json +++ b/themes/fish.json @@ -40,7 +40,7 @@ "windows_registry_icon": "", "folder_separator_icon": "", "style": "short", - "prefix": "<#193549> ", + "prefix": " ", "postfix": " " } }, diff --git a/themes/jandedobbeleer.json b/themes/jandedobbeleer.json index 61bf3bc6..f5beb488 100644 --- a/themes/jandedobbeleer.json +++ b/themes/jandedobbeleer.json @@ -122,7 +122,7 @@ "always_enabled": true, "error_color": "#f1184c", "color_background": true, - "prefix": "<#193549> " + "prefix": " " } } ]