diff --git a/src/color/ansi.go b/src/color/ansi.go index 8bfee2ce..4d1c5af0 100644 --- a/src/color/ansi.go +++ b/src/color/ansi.go @@ -77,33 +77,33 @@ func (a *Ansi) Init(shellName string) { a.dimmed = "%%{\x1b[2m%%}%s%%{\x1b[22m%%}" a.strikethrough = "%%{\x1b[9m%%}%s%%{\x1b[29m%%}" case shell.BASH: - a.format = "\001%s\002" - a.linechange = "\001\x1b[%d%s\002" - a.right = "\001\x1b[%dC\002" - a.left = "\001\x1b[%dD\002" - a.creset = "\001\x1b[0m\002" - a.clearBelow = "\001\x1b[0J\002" - a.clearLine = "\001\x1b[K\002" - a.saveCursorPosition = "\001\x1b7\002" - a.restoreCursorPosition = "\001\x1b8\002" - a.title = "\001\x1b]0;%s\007\002" - a.colorSingle = "\001\x1b[%sm\002%s\001\x1b[0m\002" - a.colorFull = "\001\x1b[%sm\x1b[%sm\002%s\001\x1b[0m\002" - a.colorTransparent = "\001\x1b[%s;49m\x1b[7m\002%s\001\x1b[0m\002" - a.escapeLeft = "\001" - a.escapeRight = "\002" - a.hyperlink = "\001\x1b]8;;%s\x1b\\\\\002%s\001\x1b]8;;\x1b\\\\\002" - a.hyperlinkRegex = `(?P\001\x1b\]8;;(.+)\x1b\\\\\002(?P.+)\001\x1b\]8;;\x1b\\\\\002)` - a.osc99 = "\001\x1b]9;9;\"%s\"\x1b\\\\\002" - a.osc7 = "\001\x1b]7;\"file://%s/%s\"\x1b\\\\\002" - a.bold = "\001\x1b[1m\002%s\001\x1b[22m\002" - a.italic = "\001\x1b[3m\002%s\001\x1b[23m\002" - a.underline = "\001\x1b[4m\002%s\001\x1b[24m\002" - a.overline = "\001\x1b[53m\002%s\001\x1b[55m\002" - a.blink = "\001\x1b[5m\002%s\001\x1b[25m\002" - a.reverse = "\001\x1b[7m\002%s\001\x1b[27m\002" - a.dimmed = "\001\x1b[2m\002%s\001\x1b[22m\002" - a.strikethrough = "\001\x1b[9m\002%s\001\x1b[29m\002" + a.format = "\\[%s\\]" + a.linechange = "\\[\x1b[%d%s\\]" + a.right = "\\[\x1b[%dC\\]" + a.left = "\\[\x1b[%dD\\]" + a.creset = "\\[\x1b[0m\\]" + a.clearBelow = "\\[\x1b[0J\\]" + a.clearLine = "\\[\x1b[K\\]" + a.saveCursorPosition = "\\[\x1b7\\]" + a.restoreCursorPosition = "\\[\x1b8\\]" + a.title = "\\[\x1b]0;%s\007\\]" + a.colorSingle = "\\[\x1b[%sm\\]%s\\[\x1b[0m\\]" + a.colorFull = "\\[\x1b[%sm\x1b[%sm\\]%s\\[\x1b[0m\\]" + a.colorTransparent = "\\[\x1b[%s;49m\x1b[7m\\]%s\\[\x1b[0m\\]" + a.escapeLeft = "\\[" + a.escapeRight = "\\]" + a.hyperlink = "\\[\x1b]8;;%s\x1b\\\\\\]%s\\[\x1b]8;;\x1b\\\\\\]" + a.hyperlinkRegex = `(?P\\\[\x1b\]8;;(.+)\x1b\\\\\\\](?P.+)\\\[\x1b\]8;;\x1b\\\\\\\])` + a.osc99 = "\\[\x1b]9;9;\"%s\"\x1b\\\\\\]" + a.osc7 = "\\[\x1b]7;\"file://%s/%s\"\x1b\\\\\\]" + a.bold = "\\[\x1b[1m\\]%s\\[\x1b[22m\\]" + a.italic = "\\[\x1b[3m\\]%s\\[\x1b[23m\\]" + a.underline = "\\[\x1b[4m\\]%s\\[\x1b[24m\\]" + a.overline = "\\[\x1b[53m\\]%s\\[\x1b[55m\\]" + a.blink = "\\[\x1b[5m\\]%s\\[\x1b[25m\\]" + a.reverse = "\\[\x1b[7m\\]%s\\[\x1b[27m\\]" + a.dimmed = "\\[\x1b[2m\\]%s\\[\x1b[22m\\]" + a.strikethrough = "\\[\x1b[9m\\]%s\\[\x1b[29m\\]" default: a.format = "%s" a.linechange = "\x1b[%d%s" diff --git a/src/color/ansi_test.go b/src/color/ansi_test.go index d7a0d374..2dd0a230 100644 --- a/src/color/ansi_test.go +++ b/src/color/ansi_test.go @@ -33,7 +33,7 @@ func TestGenerateHyperlinkWithUrl(t *testing.T) { }{ {Text: "[google](http://www.google.be)", ShellName: shell.ZSH, Expected: "%{\x1b]8;;http://www.google.be\x1b\\%}google%{\x1b]8;;\x1b\\%}"}, {Text: "[google](http://www.google.be)", ShellName: shell.PWSH, Expected: "\x1b]8;;http://www.google.be\x1b\\google\x1b]8;;\x1b\\"}, - {Text: "[google](http://www.google.be)", ShellName: shell.BASH, Expected: "\001\x1b]8;;http://www.google.be\x1b\\\\\002google\001\x1b]8;;\x1b\\\\\002"}, + {Text: "[google](http://www.google.be)", ShellName: shell.BASH, Expected: "\\[\x1b]8;;http://www.google.be\x1b\\\\\\]google\\[\x1b]8;;\x1b\\\\\\]"}, } for _, tc := range cases { a := Ansi{}