Open LunarLambda opened 1 year ago
I've also had this issue for a while now
it occured to me that it may be conflicting with the LESS_TERMCAP_*
environment variables that can be used to do colorization in less without needing to use an external highlighter
however even after unsetting them, the result is exactly identical, so it doesn't appear to be the issue.
I tried getting less to not do any of its own highlighting (bold/underline) but none of the options I tried had any effect either.
I don't have set any LESSTERMCAP environment variables, but I'm having the issue too.
Looks like someone found a workaround here https://github.com/sharkdp/bat/issues/2593#issuecomment-1636468711
Same problem as @christianhauff. EDIT: Apparently the culprit is groff v1.23, so I added this to .zshrc and .bashrc
export MANROFFOPT='-c'
I don't know what this actually does, but it seems to work.
This has fixed the problem for me.
I've the same problem :
even if I export the option MANROFFOPT='-c'
(or GROFF_NO_SGR=1
) :
on the contrary, ^H
appear in every corner.
most
doesn't seem to be affected :
regards, lacsaP.
the joint use of the omitted col
in my MANPAGER
definition (eg. export MANPAGER='sh -c "col -bx | bat -l man -p"'
) and the MANROFFOPT
option (eg. export MANROFFOPT='-c'
) solves the ^H
problem :
however, bat
doesn't seem to honor the PAGER
environment variable : PAGER='most' man man
has no effect because bat
continues to use less
as pager (nb. BAT_PAGER=most man man
uses most
as pager as requested).
I don't know if it's a bug, but coloring is discontinuous when accented characters are encountered :
(LANG="fr_FR.UTF-8" man man
)
regards, lacsaP.
The workaround seems to work for me for man pages. (setting MANROFFOPT to -c, and removing decorations with col -bx in MANPAGER).
Unfortunately, some programs respect MANPAGER but not not MANROFFOPT. For example, aws help. In that case, the output is all messed up. See screenshot
I might be wrong, but if my understanding is correct, the problem is that by default (without nroff default output), bat feeds text with ansi escape characters to HighlightLines. HighlightLines tries to parse Manpages content, but does not expect the content to contain ansi and get confused. Actually, if I remove the function-call
include and rebuild the assets and rebuild bat, the initial garbage does not appear.
I found a workaround that works with man, and with aws help: I leave MANROFFOPT
empty. So nroff outputs content with ansi espace sequences. And I remove them in the MANPAGER step with MANPAGER="sh -c \"sed -e 's/\x1b\[[0-9;]*m//g'
It does the trick. But it seems to me that in ideal world, bat should accept content with ansi escape sequences, and remove them before passing the string to HighlightLines
How did you install
bat
?Archlinux repositories
man 1 ls
man 1 zshall
man 1 ls
, withMANPAGER="sh -c 'col -bx | bat -plman'"
bat version and environment
Software version
bat 0.23.0 (871abd27)
Operating system
Linux 6.4.11-arch2-1
Command-line
Environment variables
System Config file
Could not read contents of '/etc/bat/config': No such file or directory (os error 2).
Config file
Could not read contents of '/home/lambda/cfg/bat/config': No such file or directory (os error 2).
Custom assets metadata
Could not read contents of '/home/lambda/.cache/bat/metadata.yaml': No such file or directory (os error 2).
Custom assets
'/home/lambda/.cache/bat' not found
Compile time information
Less version
Terminal is xfce4-terminal (
VTE_VERSION
7202,TERM
xterm-256color)