From 2b4299d3d32af698452190a248a52c269cd3b0eb Mon Sep 17 00:00:00 2001 From: Janne Koschinski Date: Tue, 22 Aug 2017 21:47:42 +0200 Subject: [PATCH] Fixed an issue where backticks were not properly escaped --- defaults.go | 8 +++++--- powerline.go | 1 + segment-cwd.go | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/defaults.go b/defaults.go index b01a984d..edc95bc2 100644 --- a/defaults.go +++ b/defaults.go @@ -21,8 +21,7 @@ var symbolTemplates = map[string]Symbols{ RepoUntracked: "+", RepoConflicted: "\u273C", }, - "flat": { - }, + "flat": {}, } var shellInfos = map[string]ShellInfo{ @@ -30,18 +29,21 @@ var shellInfos = map[string]ShellInfo{ colorTemplate: "\\[\\e%s\\]", rootIndicator: " \\$ ", escapedBackslash: `\\\\`, + escapedBacktick: "\\`", escapedDollar: `\$`, }, "zsh": { colorTemplate: "%%{\u001b%s%%}", rootIndicator: " %# ", escapedBackslash: `\\`, + escapedBacktick: "\\`", escapedDollar: `\$`, }, "bare": { - colorTemplate: "%s", + colorTemplate: "%s", rootIndicator: " $ ", escapedBackslash: `\`, + escapedBacktick: "`", escapedDollar: `$`, }, } diff --git a/powerline.go b/powerline.go index aca6c221..a30ea217 100644 --- a/powerline.go +++ b/powerline.go @@ -10,6 +10,7 @@ type ShellInfo struct { rootIndicator string colorTemplate string escapedDollar string + escapedBacktick string escapedBackslash string } diff --git a/segment-cwd.go b/segment-cwd.go index 67c17a88..cc24042d 100644 --- a/segment-cwd.go +++ b/segment-cwd.go @@ -57,6 +57,7 @@ func maybeShortenName(p *powerline, pathSegment string) string { func escapeVariables(p *powerline, pathSegment string) string { pathSegment = strings.Replace(pathSegment, `\`, p.shellInfo.escapedBackslash, -1) + pathSegment = strings.Replace(pathSegment, "`", p.shellInfo.escapedBacktick, -1) pathSegment = strings.Replace(pathSegment, `$`, p.shellInfo.escapedDollar, -1) return pathSegment }