Syntax highlighting doesn't work properly for fish man pages
injust opened this issue · 3 comments
What steps will reproduce the bug?
- Use fish shell
set -Ux MANPAGER "sh -c 'col -bx | bat -l man -p'"
type --help
,fish_add_path --help
, etc.
What happens?
Anything that isn't indented is syntax highlighted orange, ignoring any actual formatting.
What did you expect to happen instead?
The man page should be highlighted reasonably.
I think this might be happening because fish's man pages aren't indented? But I couldn't find anything suggesting that man page sections have to be indented, so if this is the reason, then the syntax highlighting should be able to tolerate fish's non-indented man page format.
How did you install bat
?
Homebrew
Software version
bat 0.24.0
Operating system
macOS 14.5 (Darwin 23.5.0)
Command-line
bat --diagnostic
Environment variables
SHELL=/usr/local/bin/fish
PAGER=<not set>
LESS=<not set>
LANG=en_CA.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 --language=man --style=plain'\'''
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 '/Users/jsu/.config/bat/config': No such file or directory (os error 2).
Custom assets metadata
bat_version: 0.24.0
creation_time:
secs_since_epoch: 1719638264
nanos_since_epoch: 856140000
Custom assets
- metadata.yaml, 97 bytes
- syntaxes.bin, 915557 bytes
- themes.bin, 57307 bytes
Compile time information
- Profile: release
- Target triple: x86_64-apple-darwin
- Family: unix
- OS: macos
- Architecture: x86_64
- Pointer width: 64
- Endian: little
- CPU features: cmpxchg16b,fxsr,popcnt,sse,sse2,sse3,sse4.1,sse4.2,ssse3
- Host: x86_64-apple-darwin
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
Hi,
I have a similar issue, I think. I use zsh 5.9, bat 0.24 (installed via arch official repository) and I have MANPAGER=sh -c 'col -bx | bat -l man -p'
too.
Not everything is orange for me but I have some color character which make it hard to read.
It works better with MANPAGER="bat -l man"`
But sometimes the behavior is very strange.
Let me know if you need more info.
Thank you
@flohw Think your issue is different.
Can you check your groff version using
groff -v
And if it's 1.23.0, try adding MANROFFOPT='-c'
and that should fix it.
After some experimentations with my env vars, defining this variable worked fine.
Thank you
Some explanation if anyone struggle to configure it to their need:
# For global use across the system (in your bashrc/zshrc)
export MANROFFOPT='-c'
# For local script global useage
MANROFFOPT='-c'
man -P "$MANPAGER' --paging always'" <man entry>
# For online usage
MANROFFOPT='-c' man -P $MANPAGER <man entry>
Note that I haven't tested each one and only based them on my experience. I hope to not have make mistake. :-)