bat icon indicating copy to clipboard operation
bat copied to clipboard

git --help breaks with bat manpager

Open ranile opened this issue 2 years ago • 5 comments

What steps will reproduce the bug?

  1. MANPAGER="sh -c 'col -bx | bat -l man -p'" git commit --help
  2. observe

What happens?

The bolded text is misformatted: image

What did you expect to happen instead?

The text to appear fine

How did you install bat?

pacman


bat version and environment

Software version

bat 0.24.0 (fc954685)

Operating system

Linux 6.5.7-arch1-1

Command-line

bat --diagnostic 

Environment variables

SHELL=/usr/bin/fish
PAGER=<not set>
LESS=<not set>
LANG=en_US.UTF-8
LC_ALL=<not set>
BAT_PAGER=<not set>
BAT_PAGING=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=truecolor
NO_COLOR=<not set>
MANPAGER='sh -c '\''col -bx | bat -l man -p'\'''

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/user/.config/bat/config': No such file or directory (os error 2).

Custom assets metadata

Could not read contents of '/home/user/.cache/bat/metadata.yaml': No such file or directory (os error 2).

Custom assets

'/home/user/.cache/bat' not found

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-linux-gnu
  • Family: unix
  • OS: linux
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2
  • Host: x86_64-unknown-linux-gnu

Less version

> less --version 
less 643 (PCRE2 regular expressions)
Copyright (C) 1984-2023  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less

ranile avatar Oct 30 '23 17:10 ranile

Interesting, that exact same invocation works fine for me with no spurious 4m etc stuff in the output. Just as a quick sanity check, does it make a difference with --pager=never in the mix? i.e. MANPAGER="sh -c 'col -bx | bat -l man -p --pager=never'" git commit --help

keith-hall avatar Oct 31 '23 20:10 keith-hall

I just tried it and no, it's the highlighting that's messing up, not the pager

ranile avatar Oct 31 '23 20:10 ranile

groff version? If 1.23.0, adding MANROFFOPT='-c' will probably fix the output.

cf. https://github.com/sharkdp/bat/issues/2593#issuecomment-1636468711

stardust-and-raindrops avatar Nov 03 '23 16:11 stardust-and-raindrops

groff version? If 1.23.0, adding MANROFFOPT='-c' will probably fix the output.

cf. #2593 (comment)

Running MANPAGER="sh -c 'col -bx | bat -l man -p'" MANROFFOPT='-c' git commit --help fixes it, thanks for help. Perhaps this should be added in the README?

$ groff -v
GNU groff version 1.23.0
Copyright (C) 2022 Free Software Foundation, Inc.
GNU groff comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of groff and its subprograms
under the terms of the GNU General Public License.
For more information about these matters, see the file
named COPYING.

called subprograms:

GNU grops (groff) version 1.23.0
GNU troff (groff) version 1.23.0

ranile avatar Nov 05 '23 12:11 ranile

Running MANPAGER="sh -c 'col -bx | bat -l man -p'" MANROFFOPT='-c' git commit --help fixes it, thanks for help. Perhaps this should be added in the README?

It has already been added in README.md, about 4 years ago (#45f3c733)!

Diti avatar Nov 23 '23 20:11 Diti