fix(bash): replace all single occurances of \

This commit is contained in:
Jan De Dobbeleer 2022-05-12 07:51:42 +02:00 committed by Jan De Dobbeleer
parent 6a7f03eb5b
commit 8c9b6358b5

View file

@ -7,6 +7,7 @@ import (
"oh-my-posh/environment"
"oh-my-posh/properties"
"oh-my-posh/segments"
"oh-my-posh/shell"
"oh-my-posh/template"
"runtime/debug"
"strings"
@ -352,5 +353,11 @@ func (segment *Segment) SetText() {
return
}
segment.text = segment.string()
// see https://github.com/JanDeDobbeleer/oh-my-posh/discussions/2255
// this can't happen where we do regular text replacement in ansi.go
// as that would also replace valid \[\] sequences and break the prompt
if segment.env.Shell() == shell.BASH {
segment.text = strings.ReplaceAll(segment.text, `\`, `\\`)
}
segment.Enabled = len(strings.ReplaceAll(segment.text, " ", "")) > 0
}