diff --git a/src/engine/block.go b/src/engine/block.go index f07e4d4b..21410507 100644 --- a/src/engine/block.go +++ b/src/engine/block.go @@ -176,38 +176,70 @@ func (b *Block) writeSeparator(final bool) { if isPreviousDiamond { b.adjustTrailingDiamondColorOverrides() } + if isPreviousDiamond && isCurrentDiamond && len(b.activeSegment.LeadingDiamond) == 0 { b.writer.Write(ansi.Background, ansi.ParentBackground, b.previousActiveSegment.TrailingDiamond) return } + if isPreviousDiamond && len(b.previousActiveSegment.TrailingDiamond) > 0 { b.writer.Write(ansi.Transparent, ansi.ParentBackground, b.previousActiveSegment.TrailingDiamond) } - resolvePowerlineSymbol := func() string { - var symbol string - if b.activeSegment.isPowerline() { - symbol = b.activeSegment.PowerlineSymbol - } else if b.previousActiveSegment != nil && b.previousActiveSegment.isPowerline() { - symbol = b.previousActiveSegment.PowerlineSymbol + isPowerline := b.activeSegment.isPowerline() + + shouldOverridePowerlineLeadingSymbol := func() bool { + if !isPowerline { + return false } - return symbol + + if isPowerline && len(b.activeSegment.LeadingPowerlineSymbol) == 0 { + return false + } + + if b.previousActiveSegment != nil && b.previousActiveSegment.isPowerline() { + return false + } + + return true } + + if shouldOverridePowerlineLeadingSymbol() { + b.writer.Write(ansi.Transparent, ansi.Background, b.activeSegment.LeadingPowerlineSymbol) + return + } + + resolvePowerlineSymbol := func() string { + if isPowerline { + return b.activeSegment.PowerlineSymbol + } + + if b.previousActiveSegment != nil && b.previousActiveSegment.isPowerline() { + return b.previousActiveSegment.PowerlineSymbol + } + + return "" + } + symbol := resolvePowerlineSymbol() if len(symbol) == 0 { return } + bgColor := ansi.Background - if final || !b.activeSegment.isPowerline() { + if final || !isPowerline { bgColor = ansi.Transparent } + if b.activeSegment.style() == Diamond && len(b.activeSegment.LeadingDiamond) == 0 { bgColor = ansi.Background } + if b.activeSegment.InvertPowerline { b.writer.Write(b.getPowerlineColor(), bgColor, symbol) return } + b.writer.Write(bgColor, b.getPowerlineColor(), symbol) } diff --git a/src/engine/segment.go b/src/engine/segment.go index 1d8be362..aa26c35c 100644 --- a/src/engine/segment.go +++ b/src/engine/segment.go @@ -20,26 +20,27 @@ import ( // Segment represent a single segment and it's configuration type Segment struct { - Type SegmentType `json:"type,omitempty" toml:"type,omitempty"` - Tips []string `json:"tips,omitempty" toml:"tips,omitempty"` - Style SegmentStyle `json:"style,omitempty" toml:"style,omitempty"` - PowerlineSymbol string `json:"powerline_symbol,omitempty" toml:"powerline_symbol,omitempty"` - InvertPowerline bool `json:"invert_powerline,omitempty" toml:"invert_powerline,omitempty"` - Foreground string `json:"foreground,omitempty" toml:"foreground,omitempty"` - ForegroundTemplates template.List `json:"foreground_templates,omitempty" toml:"foreground_templates,omitempty"` - Background string `json:"background,omitempty" toml:"background,omitempty"` - BackgroundTemplates template.List `json:"background_templates,omitempty" toml:"background_templates,omitempty"` - LeadingDiamond string `json:"leading_diamond,omitempty" toml:"leading_diamond,omitempty"` - TrailingDiamond string `json:"trailing_diamond,omitempty" toml:"trailing_diamond,omitempty"` - Template string `json:"template,omitempty" toml:"template,omitempty"` - Templates template.List `json:"templates,omitempty" toml:"templates,omitempty"` - TemplatesLogic template.Logic `json:"templates_logic,omitempty" toml:"templates_logic,omitempty"` - Properties properties.Map `json:"properties,omitempty" toml:"properties,omitempty"` - Interactive bool `json:"interactive,omitempty" toml:"interactive,omitempty"` - Alias string `json:"alias,omitempty" toml:"alias,omitempty"` - MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"` - MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"` - Filler string `json:"filler,omitempty" toml:"filler,omitempty"` + Type SegmentType `json:"type,omitempty" toml:"type,omitempty"` + Tips []string `json:"tips,omitempty" toml:"tips,omitempty"` + Style SegmentStyle `json:"style,omitempty" toml:"style,omitempty"` + PowerlineSymbol string `json:"powerline_symbol,omitempty" toml:"powerline_symbol,omitempty"` + LeadingPowerlineSymbol string `json:"leading_powerline_symbol,omitempty" toml:"leading_powerline_symbol,omitempty"` + InvertPowerline bool `json:"invert_powerline,omitempty" toml:"invert_powerline,omitempty"` + Foreground string `json:"foreground,omitempty" toml:"foreground,omitempty"` + ForegroundTemplates template.List `json:"foreground_templates,omitempty" toml:"foreground_templates,omitempty"` + Background string `json:"background,omitempty" toml:"background,omitempty"` + BackgroundTemplates template.List `json:"background_templates,omitempty" toml:"background_templates,omitempty"` + LeadingDiamond string `json:"leading_diamond,omitempty" toml:"leading_diamond,omitempty"` + TrailingDiamond string `json:"trailing_diamond,omitempty" toml:"trailing_diamond,omitempty"` + Template string `json:"template,omitempty" toml:"template,omitempty"` + Templates template.List `json:"templates,omitempty" toml:"templates,omitempty"` + TemplatesLogic template.Logic `json:"templates_logic,omitempty" toml:"templates_logic,omitempty"` + Properties properties.Map `json:"properties,omitempty" toml:"properties,omitempty"` + Interactive bool `json:"interactive,omitempty" toml:"interactive,omitempty"` + Alias string `json:"alias,omitempty" toml:"alias,omitempty"` + MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"` + MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"` + Filler string `json:"filler,omitempty" toml:"filler,omitempty"` Enabled bool `json:"-" toml:"-"` diff --git a/themes/schema.json b/themes/schema.json index bfa75aad..833902be 100644 --- a/themes/schema.json +++ b/themes/schema.json @@ -578,7 +578,13 @@ "type": "string", "title": "Powerline Symbol", "description": "https://ohmyposh.dev/docs/configuration/segment#powerline-symbol", - "default": "\uE0B0" + "default": "\ue0b0" + }, + "leading_powerline_symbol": { + "type": "string", + "title": "Leading Powerline Symbol", + "description": "https://ohmyposh.dev/docs/configuration/segment#powerline-symbol", + "default": "\ue0d7" }, "invert_powerline": { "type": "boolean", diff --git a/website/docs/configuration/segment.mdx b/website/docs/configuration/segment.mdx index cad2a121..9b61d5a0 100644 --- a/website/docs/configuration/segment.mdx +++ b/website/docs/configuration/segment.mdx @@ -33,26 +33,27 @@ understand how to configure a segment. } ``` -| Name | Type | Description | -| ---------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `type` | `string` | takes the `string` value referencing which segment logic it needs to run (see [segments][segments] for possible values) | -| `style` | `string` | see [Style][style] below. Possible values: