mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
fix(tcsh): escape special characters correctly
This commit is contained in:
parent
a8f246064e
commit
c7793a5f29
|
@ -108,17 +108,19 @@ func (e *Engine) pwd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) getNewline() string {
|
func (e *Engine) getNewline() string {
|
||||||
// WARP terminal will remove \n from the prompt, so we hack a newline in.
|
if e.Plain || e.Env.Flags().Debug {
|
||||||
|
return "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warp terminal will remove a newline character ('\n') from the prompt, so we hack it in.
|
||||||
// For Elvish, we do this to prevent cutting off a right-aligned block.
|
// For Elvish, we do this to prevent cutting off a right-aligned block.
|
||||||
if e.isWarp() || e.Env.Shell() == shell.ELVISH {
|
if e.isWarp() || e.Env.Shell() == shell.ELVISH {
|
||||||
return terminal.LineBreak()
|
return terminal.LineBreak()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TCSH needs a space before the LITERAL newline character or it will not render correctly
|
// To avoid improper translations in Tcsh, we use an invisible word joiner character (U+2060) to separate a newline from possible preceding escape sequences.
|
||||||
// don't ask why, it be like that sometimes.
|
|
||||||
// https://unix.stackexchange.com/questions/99101/properly-defining-a-multi-line-prompt-in-tcsh#comment1342462_322189
|
|
||||||
if e.Env.Shell() == shell.TCSH {
|
if e.Env.Shell() == shell.TCSH {
|
||||||
return ` \n`
|
return "\u2060\\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
return "\n"
|
return "\n"
|
||||||
|
|
|
@ -73,6 +73,9 @@ func GetFormats(shell string) *Formats {
|
||||||
ITermPromptMark: "%{$(iterm2_prompt_mark)%}",
|
ITermPromptMark: "%{$(iterm2_prompt_mark)%}",
|
||||||
ITermCurrentDir: "%%{\x1b]1337;CurrentDir=%s\x07%%}",
|
ITermCurrentDir: "%%{\x1b]1337;CurrentDir=%s\x07%%}",
|
||||||
ITermRemoteHost: "%%{\x1b]1337;RemoteHost=%s@%s\x07%%}",
|
ITermRemoteHost: "%%{\x1b]1337;RemoteHost=%s@%s\x07%%}",
|
||||||
|
EscapeSequences: map[rune]string{
|
||||||
|
'%': "%%",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
formats = &Formats{
|
formats = &Formats{
|
||||||
|
@ -98,10 +101,9 @@ func GetFormats(shell string) *Formats {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if shell == ZSH {
|
if shell == TCSH {
|
||||||
formats.EscapeSequences = map[rune]string{
|
formats.EscapeSequences['\\'] = `\\`
|
||||||
'%': "%%",
|
formats.EscapeSequences['!'] = `\!`
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return formats
|
return formats
|
||||||
|
|
Loading…
Reference in a new issue