diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index b68d754cbd43..536e175f91d0 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -195,6 +195,63 @@ Text character to use when `"style": "powerline"`. If `true` this swaps the foreground and background colors. Can be useful when the character you want does not exist in the perfectly mirrored variant for example. +### Hide Separator + +By default a separator between a powerline segment and a diamond/plain segment will be rendered. If `true` this removes +the separator. Can be useful when you want a powerline that is right next to other segments. + +Notice: If you have segments that is NOT always enabled, be sure to set EVERY of them till the first always-enabled segment. + +```jsonc +{ + "segments": [ + { + "type": "session", + "style": "diamond", + "foreground": "#ffffff", + "background": "#ffb300", + "leading_diamond": "\uE0B6", + // in this case a trailing_diamond is not required + }, + { + "type": "go", + "style": "powerline", + "powerline_symbol": "\uE0B0", + "foreground": "#ffffff", + "background": "#61AFEF", + "hide_separator": true, + // hide_separator is required here + "properties": { + "always_enabled": false, + } + }, + { + "type": "path", + "style": "powerline", + "powerline_symbol": "\uE0B0", + "foreground": "#193549", + "background": "#ffeb3b", + "hide_separator": true, + // hide_separator is also required here + "properties": { + "always_enabled": true, + } + }, + { + "type": "git", + "style": "powerline", + "powerline_symbol": "\uE0B0", + "foreground": "#ffffff", + "background": "#61AFEF", + // hide_separator is not required here + "properties": { + "always_enabled": false, + } + }, + ] +} +``` + ### Leading diamond Text character to use at the start of the segment. Will take the background color of the segment as diff --git a/src/block.go b/src/block.go index d6f2f5c7de0b..c9c41aec8989 100644 --- a/src/block.go +++ b/src/block.go @@ -92,7 +92,8 @@ func (b *Block) endPowerline() { if b.activeSegment != nil && b.activeSegment.Style != Powerline && b.previousActiveSegment != nil && - b.previousActiveSegment.Style == Powerline { + b.previousActiveSegment.Style == Powerline && + !b.previousActiveSegment.HideSeparator { b.writePowerLineSeparator(b.getPowerlineColor(false), b.previousActiveSegment.background(), true) } } @@ -116,7 +117,7 @@ func (b *Block) getPowerlineColor(foreground bool) string { if !foreground && b.activeSegment.Style != Powerline { return Transparent } - if foreground && b.previousActiveSegment.Style != Powerline { + if foreground && b.previousActiveSegment.Style != Powerline && !b.activeSegment.HideSeparator { return Transparent } return b.previousActiveSegment.background() @@ -144,7 +145,11 @@ func (b *Block) renderPlainSegment(text string) { } func (b *Block) renderDiamondSegment(text string) { - b.writer.write(Transparent, b.activeSegment.background(), b.activeSegment.LeadingDiamond) + if b.previousActiveSegment != nil && b.previousActiveSegment.HideSeparator { + b.writer.write(b.previousActiveSegment.background(), b.activeSegment.background(), b.activeSegment.LeadingDiamond) + } else { + b.writer.write(Transparent, b.activeSegment.background(), b.activeSegment.LeadingDiamond) + } b.renderText(text) b.writer.write(Transparent, b.activeSegment.background(), b.activeSegment.TrailingDiamond) } diff --git a/src/segment.go b/src/segment.go index 4e0d5c04efe2..d0b3e05d7a1b 100644 --- a/src/segment.go +++ b/src/segment.go @@ -18,6 +18,7 @@ type Segment struct { BackgroundTemplates []string `config:"background_templates"` LeadingDiamond string `config:"leading_diamond"` TrailingDiamond string `config:"trailing_diamond"` + HideSeparator bool `config:"hide_separator"` Properties map[Property]interface{} `config:"properties"` props *properties writer SegmentWriter diff --git a/themes/powerlevel10k_rainbow.omp.json b/themes/powerlevel10k_rainbow.omp.json new file mode 100644 index 000000000000..225f57a48ccf --- /dev/null +++ b/themes/powerlevel10k_rainbow.omp.json @@ -0,0 +1,237 @@ +{ + "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh3/main/themes/schema.json", + "blocks": [ + { + "type": "prompt", + "alignment": "left", + "newline": true, + "segments": [] + }, + { + "type": "prompt", + "alignment": "left", + "newline": true, + "segments": [ + { + "type": "os", + "style": "diamond", + "foreground": "#000000", + "background": "#d3d7cf", + "leading_diamond": "╭─" + }, + { + "type": "path", + "style": "powerline", + "powerline_symbol": "", + "foreground": "#e4e4e4", + "background": "#3465a4", + "hide_separator": true, + "properties": { + "prefix": " \uF07C ", + "home_icon": "~", + "style": "full" + } + }, + { + "type": "git", + "style": "powerline", + "powerline_symbol": "", + "foreground": "#000000", + "background": "#4e9a06", + "properties": { + "branch_icon": "\uF126 ", + "display_stash_count": true, + "display_upstream_icon": true, + "status_colors_enabled": true, + "local_changes_color": "#c4a000", + "ahead_and_behind_color": "#f26d50", + "behind_color": "#4e9a06", + "ahead_color": "#89d1dc", + "stash_count_icon": "\uF692 " + } + } + ] + }, + { + "type": "prompt", + "alignment": "right", + "segments": [ + { + "type": "node", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": true, + "foreground": "#ffffff", + "background": "#689f63", + "properties": { + "postfix": " \uF898 ", + "display_version": true + } + }, + { + "type": "go", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": true, + "foreground": "#111111", + "background": "#00acd7", + "properties": { + "postfix": " \uE627 ", + "display_version": true + } + }, + { + "type": "julia", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": true, + "foreground": "#111111", + "background": "#4063D8", + "properties": { + "postfix": " \uE624 ", + "display_version": true + } + }, + { + "type": "python", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": true, + "foreground": "#111111", + "background": "#FFDE57", + "properties": { + "postfix": " \uE235 ", + "display_version": true, + "display_mode": "files", + "display_virtual_env": false + } + }, + { + "type": "ruby", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": true, + "foreground": "#ffffff", + "background": "#AE1401", + "properties": { + "postfix": " \uE791 ", + "display_version": true, + "display_mode": "files" + } + }, + { + "type": "azfunc", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": true, + "foreground": "#ffffff", + "background": "#FEAC19", + "properties": { + "postfix": " \uf0e7", + "display_version": false, + "display_mode": "files" + } + }, + { + "type": "aws", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": true, + "foreground": "#ffffff", + "background_templates": [ + "{{if contains \"default\" .Profile}}#FFA400{{end}}", + "{{if contains \"jan\" .Profile}}#f1184c{{end}}" + ], + "properties": { + "postfix": " \uE7AD ", + "display_default": false + } + }, + { + "type": "root", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": true, + "foreground": "#111111", + "background": "#ffff66", + "properties": { + "root_icon": "\uF0AD" + } + }, + { + "type": "executiontime", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": true, + "foreground": "#000000", + "background": "#c4a000", + "properties": { + "postfix": " \uF252 " + } + }, + { + "type": "exit", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": true, + "foreground": "#d3d7cf", + "background": "#000000", + "hide_separator": true, + "properties": { + "always_enabled": true, + "display_exit_code": true, + "error_color": "#cc2222", + "color_background": true, + "success_icon": "✔" + } + }, + { + "type": "time", + "style": "diamond", + "invert_powerline": true, + "leading_diamond": "", + "trailing_diamond": "─╮", + "background": "#d3d7cf", + "foreground": "#000000", + "properties": { + "postfix": " \uF017 " + } + } + ] + }, + { + "type": "prompt", + "alignment": "left", + "newline": true, + "segments": [ + { + "type": "text", + "style": "diamond", + "background": "#d3d7cf", + "trailing_diamond": "\b╰─", + "properties": { + "text": "\b" + } + } + ] + }, + { + "type": "rprompt", + "segments": [ + { + "type": "text", + "style": "diamond", + "background": "#d3d7cf", + "trailing_diamond": "─╯", + "properties": { + "text": "" + } + } + ] + } + ], + "final_space": true, + "console_title": true, + "console_title_style": "template", + "console_title_template": "{{ .Shell }} in {{ .Folder }}" +} diff --git a/themes/schema.json b/themes/schema.json index de0f0373ea61..a01576f06cb2 100644 --- a/themes/schema.json +++ b/themes/schema.json @@ -234,6 +234,12 @@ "title": "Flip the Powerline symbol vertically", "description": "https://ohmyposh.dev/docs/configure#invert-powerline", "default": false + }, + "hide_separator": { + "type": "boolean", + "title": "Hide the separator between a Powerline segment and others", + "description": "https://ohmyposh.dev/docs/configure#hide_separator", + "default": false } } }