mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
feat: render rprompt separately
This commit is contained in:
parent
19544bff9b
commit
1d192d63d8
|
@ -254,3 +254,24 @@ func (e *engine) renderTransientPrompt() string {
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *engine) renderRPrompt() string {
|
||||||
|
filterRPromptBlock := func(blocks []*Block) *Block {
|
||||||
|
for _, block := range blocks {
|
||||||
|
if block.Type == RPrompt {
|
||||||
|
return block
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
block := filterRPromptBlock(e.config.Blocks)
|
||||||
|
if block == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
block.init(e.env, e.writer, e.ansi)
|
||||||
|
block.setStringValues()
|
||||||
|
if !block.enabled() {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return block.renderSegments()
|
||||||
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ type args struct {
|
||||||
Author *string
|
Author *string
|
||||||
CursorPadding *int
|
CursorPadding *int
|
||||||
RPromptOffset *int
|
RPromptOffset *int
|
||||||
|
RPrompt *bool
|
||||||
BGColor *string
|
BGColor *string
|
||||||
StackCount *int
|
StackCount *int
|
||||||
Command *string
|
Command *string
|
||||||
|
@ -141,6 +142,10 @@ func main() {
|
||||||
"rprompt-offset",
|
"rprompt-offset",
|
||||||
40,
|
40,
|
||||||
"Offset the right prompt with x when using --export-img"),
|
"Offset the right prompt with x when using --export-img"),
|
||||||
|
RPrompt: flag.Bool(
|
||||||
|
"rprompt",
|
||||||
|
false,
|
||||||
|
"Only print the rprompt block"),
|
||||||
BGColor: flag.String(
|
BGColor: flag.String(
|
||||||
"bg-color",
|
"bg-color",
|
||||||
"#151515",
|
"#151515",
|
||||||
|
@ -230,6 +235,10 @@ func main() {
|
||||||
fmt.Print(engine.renderTooltip(*args.Command))
|
fmt.Print(engine.renderTooltip(*args.Command))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if *args.RPrompt {
|
||||||
|
fmt.Print(engine.renderRPrompt())
|
||||||
|
return
|
||||||
|
}
|
||||||
prompt := engine.render()
|
prompt := engine.render()
|
||||||
if !*args.ExportPNG {
|
if !*args.ExportPNG {
|
||||||
fmt.Print(prompt)
|
fmt.Print(prompt)
|
||||||
|
|
Loading…
Reference in a new issue