Open oficsu opened 2 weeks ago
Issue #2751 is related and this comment also provides a shell workaround.
@einfachIrgendwer0815, unfortunately, this workaround will break syntax highlighting, which goes completely against the initial purpose of using bat for syntax highlighting:
echo Lorem ipsum dolor sit a met, \
consectetur adipiscing elit. \
Nullam venenatis nec est \
eu tristique \
| bat -p \
| fold -w 12 -s \
| bat --decorations=never \
--paging=never \
--language bash \
--theme Nord \
--color=always \
-
Ok, I just have found a better workaround that works in my case:
echo Lorem ipsum dolor sit a met, \
consectetur adipiscing elit. \
Nullam venenatis nec est \
eu tristique \
| fold -w 12 -s \
`# replace newlines by unique` \
`# invisible character that ` \
`# is ignored by syntax ` \
`# highlighting ` \
| sed -zE "s/\n/\x2062/g" \
| bat --decorations=never \
--paging=never \
--language bash \
--theme Nord \
--color=always \
- \
`# revert it back ` \
| sed -zE "s/\x2062/\n/g"
The current
--wrap character
behaviorSuggestion
I suggest a new
word
mode for the--wrap
option, which will split lines only by spaces (except in cases where a word is too long for a single line). These spaces should then be strippedAn example of how it should look with
--wrap word
: