fix(fish): escape known sequences

This commit is contained in:
Jan De Dobbeleer 2022-04-04 12:28:58 +02:00 committed by Jan De Dobbeleer
parent 865ba58a07
commit e4a60aa070

View file

@ -119,8 +119,6 @@ func (a *Ansi) Init(shellName string) {
a.escapeLeft = ""
a.escapeRight = ""
a.hyperlink = "\x1b]8;;%s\x1b\\%s\x1b]8;;\x1b\\"
// a.hyperlinkRegex = "(?P<STR>\x1b]8;;(.+)\x1b\\(?P<TEXT>.+)\x1b]8;;\x1b\\)"
// \x1b]8;;https://ohmyposh.dev\x1b\\link\x1b]8;;\x1b\\
a.hyperlinkRegex = "(?P<STR>\x1b]8;;(.+)\x1b\\\\\\\\?(?P<TEXT>.+)\x1b]8;;\x1b\\\\)"
a.osc99 = "\x1b]9;9;\"%s\"\x1b\\"
a.bold = "\x1b[1m%s\x1b[22m"
@ -131,9 +129,6 @@ func (a *Ansi) Init(shellName string) {
a.dimmed = "\x1b[2m%s\x1b[22m"
a.strikethrough = "\x1b[9m%s\x1b[29m"
}
if shellName == shell.FISH {
a.hyperlink = "\x1b]8;;%s\x1b\\\\%s\x1b]8;;\x1b\\\\"
}
}
func (a *Ansi) InitPlain(shellName string) {
@ -147,7 +142,6 @@ func (a *Ansi) initEscapeSequences(shellName string) {
// escape double quotes and variable expansion
a.reservedSequences = []sequenceReplacement{
{text: "`", replacement: "'"},
// {text: `\`, replacement: `\\`},
{text: `%l`, replacement: `%%l`},
{text: `%M`, replacement: `%%M`},
{text: `%m`, replacement: `%%m`},
@ -219,6 +213,17 @@ func (a *Ansi) initEscapeSequences(shellName string) {
{text: `\$`, replacement: `\\$`},
{text: `\nnn`, replacement: `\\nnn`},
}
case shell.FISH:
a.reservedSequences = []sequenceReplacement{
{text: "`", replacement: "'"},
{text: `\a`, replacement: `\\a`},
{text: `\b`, replacement: `\\b`},
{text: `\e`, replacement: `\\e`},
{text: `\f`, replacement: `\\f`},
{text: `\r`, replacement: `\\r`},
{text: `\t`, replacement: `\\t`},
{text: `\v`, replacement: `\\v`},
}
default:
a.reservedSequences = []sequenceReplacement{
{text: "`", replacement: "'"},