mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-31 22:07:25 -08:00
fix(warp): support rprompt
This commit is contained in:
parent
1e50107ff6
commit
2cba140522
|
@ -104,8 +104,7 @@ func (e *Engine) printPWD() {
|
|||
|
||||
func (e *Engine) newline() {
|
||||
// WARP terminal will remove \n from the prompt, so we hack a newline in
|
||||
if e.Env.Getenv("TERM_PROGRAM") == "WarpTerminal" {
|
||||
// fmt.Println("TERM_PROGRAM")
|
||||
if e.isWarp() {
|
||||
e.write(e.Ansi.LineBreak())
|
||||
} else {
|
||||
e.write("\n")
|
||||
|
@ -113,6 +112,10 @@ func (e *Engine) newline() {
|
|||
e.currentLineLength = 0
|
||||
}
|
||||
|
||||
func (e *Engine) isWarp() bool {
|
||||
return e.Env.Getenv("TERM_PROGRAM") == "WarpTerminal"
|
||||
}
|
||||
|
||||
func (e *Engine) shouldFill(block *Block, length int) (string, bool) {
|
||||
if len(block.Filler) == 0 {
|
||||
return "", false
|
||||
|
@ -271,6 +274,17 @@ func (e *Engine) print() string {
|
|||
if !e.Env.Flags().Eval {
|
||||
break
|
||||
}
|
||||
// Warp doesn't support RPROMPT so we need to write it manually
|
||||
if e.isWarp() {
|
||||
e.write(e.Ansi.SaveCursorPosition())
|
||||
e.write(e.Ansi.CarriageForward())
|
||||
e.write(e.Ansi.GetCursorForRightWrite(e.rpromptLength, 0))
|
||||
e.write(e.rprompt)
|
||||
e.write(e.Ansi.RestoreCursorPosition())
|
||||
// escape double quotes contained in the prompt
|
||||
prompt := fmt.Sprintf("PS1=\"%s\"", strings.ReplaceAll(e.string(), `"`, `\"`))
|
||||
return prompt
|
||||
}
|
||||
// escape double quotes contained in the prompt
|
||||
prompt := fmt.Sprintf("PS1=\"%s\"", strings.ReplaceAll(e.string(), `"`, `\"`))
|
||||
prompt += fmt.Sprintf("\nRPROMPT=\"%s\"", e.rprompt)
|
||||
|
|
Loading…
Reference in a new issue