mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 03:49:40 -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 ""
|
||||
}
|
||||
|
||||
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
|
||||
CursorPadding *int
|
||||
RPromptOffset *int
|
||||
RPrompt *bool
|
||||
BGColor *string
|
||||
StackCount *int
|
||||
Command *string
|
||||
|
@ -141,6 +142,10 @@ func main() {
|
|||
"rprompt-offset",
|
||||
40,
|
||||
"Offset the right prompt with x when using --export-img"),
|
||||
RPrompt: flag.Bool(
|
||||
"rprompt",
|
||||
false,
|
||||
"Only print the rprompt block"),
|
||||
BGColor: flag.String(
|
||||
"bg-color",
|
||||
"#151515",
|
||||
|
@ -230,6 +235,10 @@ func main() {
|
|||
fmt.Print(engine.renderTooltip(*args.Command))
|
||||
return
|
||||
}
|
||||
if *args.RPrompt {
|
||||
fmt.Print(engine.renderRPrompt())
|
||||
return
|
||||
}
|
||||
prompt := engine.render()
|
||||
if !*args.ExportPNG {
|
||||
fmt.Print(prompt)
|
||||
|
|
Loading…
Reference in a new issue