Skip to content

Commit

Permalink
Fixed an issue where backticks were not properly escaped
Browse files Browse the repository at this point in the history
  • Loading branch information
justjanne committed Aug 22, 2017
1 parent adb0696 commit 2b4299d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,29 @@ var symbolTemplates = map[string]Symbols{
RepoUntracked: "+",
RepoConflicted: "\u273C",
},
"flat": {
},
"flat": {},
}

var shellInfos = map[string]ShellInfo{
"bash": {
colorTemplate: "\\[\\e%s\\]",
rootIndicator: " \\$ ",
escapedBackslash: `\\\\`,
escapedBacktick: "\\`",
escapedDollar: `\$`,
},
"zsh": {
colorTemplate: "%%{\u001b%s%%}",
rootIndicator: " %# ",
escapedBackslash: `\\`,
escapedBacktick: "\\`",
escapedDollar: `\$`,
},
"bare": {
colorTemplate: "%s",
colorTemplate: "%s",
rootIndicator: " $ ",
escapedBackslash: `\`,
escapedBacktick: "`",
escapedDollar: `$`,
},
}
Expand Down
1 change: 1 addition & 0 deletions powerline.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type ShellInfo struct {
rootIndicator string
colorTemplate string
escapedDollar string
escapedBacktick string
escapedBackslash string
}

Expand Down
1 change: 1 addition & 0 deletions segment-cwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 2b4299d

Please sign in to comment.