mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
fix(zsh): escape hyperlinks correctly
This commit is contained in:
parent
0c7afaa7f7
commit
00cab2e568
|
@ -66,8 +66,8 @@ func (a *Ansi) Init(shellName string) {
|
||||||
a.colorTransparent = "%%{\x1b[%s;49m\x1b[7m%%}%s%%{\x1b[0m%%}"
|
a.colorTransparent = "%%{\x1b[%s;49m\x1b[7m%%}%s%%{\x1b[0m%%}"
|
||||||
a.escapeLeft = "%{"
|
a.escapeLeft = "%{"
|
||||||
a.escapeRight = "%}"
|
a.escapeRight = "%}"
|
||||||
a.hyperlink = "%%{\x1b]8;;%s\x1b\\\\%%}%s%%{\x1b]8;;\x1b\\\\%%}"
|
a.hyperlink = "%%{\x1b]8;;%s\x1b\\%%}%s%%{\x1b]8;;\x1b\\%%}"
|
||||||
a.hyperlinkRegex = `(?P<STR>%{\x1b]8;;(.+)\x1b\\\\%}(?P<TEXT>.+)%{\x1b]8;;\x1b\\\\%})`
|
a.hyperlinkRegex = `(?P<STR>%{\x1b]8;;(.+)\x1b\\%}(?P<TEXT>.+)%{\x1b]8;;\x1b\\%})`
|
||||||
a.osc99 = "%%{\x1b]9;9;\"%s\"\x1b\\%%}"
|
a.osc99 = "%%{\x1b]9;9;\"%s\"\x1b\\%%}"
|
||||||
a.bold = "%%{\x1b[1m%%}%s%%{\x1b[22m%%}"
|
a.bold = "%%{\x1b[1m%%}%s%%{\x1b[22m%%}"
|
||||||
a.italic = "%%{\x1b[3m%%}%s%%{\x1b[23m%%}"
|
a.italic = "%%{\x1b[3m%%}%s%%{\x1b[23m%%}"
|
||||||
|
|
|
@ -31,7 +31,7 @@ func TestGenerateHyperlinkWithUrl(t *testing.T) {
|
||||||
ShellName string
|
ShellName string
|
||||||
Expected string
|
Expected string
|
||||||
}{
|
}{
|
||||||
{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.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.PWSH, Expected: "\x1b]8;;http://www.google.be\x1b\\google\x1b]8;;\x1b\\"},
|
||||||
{Text: "[google](http://www.google.be)", ShellName: shell.BASH, Expected: "\\[\x1b]8;;http://www.google.be\x1b\\\\\\]google\\[\x1b]8;;\x1b\\\\\\]"},
|
{Text: "[google](http://www.google.be)", ShellName: shell.BASH, Expected: "\\[\x1b]8;;http://www.google.be\x1b\\\\\\]google\\[\x1b]8;;\x1b\\\\\\]"},
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ func (e *Engine) print() string {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// escape double quotes contained in the prompt
|
// escape double quotes contained in the prompt
|
||||||
prompt := fmt.Sprintf("PS1=\"%s\"", strings.ReplaceAll(e.string(), "\"", "\"\""))
|
prompt := fmt.Sprintf("PS1=\"%s\"", strings.ReplaceAll(e.string(), `"`, `\"`))
|
||||||
prompt += fmt.Sprintf("\nRPROMPT=\"%s\"", e.rprompt)
|
prompt += fmt.Sprintf("\nRPROMPT=\"%s\"", e.rprompt)
|
||||||
return prompt
|
return prompt
|
||||||
case shell.PWSH, shell.PWSH5, shell.BASH, shell.PLAIN, shell.NU:
|
case shell.PWSH, shell.PWSH5, shell.BASH, shell.PLAIN, shell.NU:
|
||||||
|
|
Loading…
Reference in a new issue