mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
refactor: better engine write function
This commit is contained in:
parent
8e226ac332
commit
eb42e0c93a
|
@ -166,21 +166,22 @@ func (e *engine) render() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *engine) write() {
|
func (e *engine) write() {
|
||||||
|
switch e.env.getShellName() {
|
||||||
|
case zsh:
|
||||||
if *e.env.getArgs().Eval {
|
if *e.env.getArgs().Eval {
|
||||||
fmt.Printf("PS1=\"%s\"", e.renderer.string())
|
fmt.Printf("PS1=\"%s\"", e.renderer.string())
|
||||||
if e.env.getShellName() == zsh {
|
|
||||||
fmt.Printf("\nRPROMPT=\"%s\"", e.rprompt)
|
fmt.Printf("\nRPROMPT=\"%s\"", e.rprompt)
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
case pwsh, powershell5, bash:
|
||||||
if e.rprompt != "" && (e.env.getShellName() == pwsh || e.env.getShellName() == powershell5) {
|
if e.rprompt != "" {
|
||||||
e.renderer.saveCursorPosition()
|
e.renderer.saveCursorPosition()
|
||||||
e.renderer.carriageForward()
|
e.renderer.carriageForward()
|
||||||
e.renderer.setCursorForRightWrite(e.rprompt, 0)
|
e.renderer.setCursorForRightWrite(e.rprompt, 0)
|
||||||
e.renderer.print(e.rprompt)
|
e.renderer.print(e.rprompt)
|
||||||
e.renderer.restoreCursorPosition()
|
e.renderer.restoreCursorPosition()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fmt.Print(e.renderer.string())
|
fmt.Print(e.renderer.string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue