Skip to content

Commit

Permalink
fix: escape \ from segment value when in bash
Browse files Browse the repository at this point in the history
fix #738
  • Loading branch information
lnu authored and JanDeDobbeleer committed May 25, 2021
1 parent 2cf288e commit 2eb45b5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/block.go
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"strings"
"sync"
"time"
)
Expand Down Expand Up @@ -90,7 +91,13 @@ func (b *Block) renderSegments() string {
}
b.activeSegment = segment
b.endPowerline()
b.renderSegmentText(segment.stringValue)
segmentValue := segment.stringValue
// escape backslashes to avoid replacements
// https://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html
if b.env.getShellName() == bash {
segmentValue = strings.ReplaceAll(segment.stringValue, "\\", "\\\\")
}
b.renderSegmentText(segmentValue)
}
if b.previousActiveSegment != nil && b.previousActiveSegment.Style == Powerline {
b.writePowerLineSeparator(Transparent, b.previousActiveSegment.background(), true)
Expand Down

0 comments on commit 2eb45b5

Please sign in to comment.