Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide_separator option for powerline; new theme: powerlevel10k_rainbow #697

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions docs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions src/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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()
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions src/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
237 changes: 237 additions & 0 deletions themes/powerlevel10k_rainbow.omp.json
Original file line number Diff line number Diff line change
@@ -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 }}"
}
6 changes: 6 additions & 0 deletions themes/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down