Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bat as manpager #3053

Open
ukiyocode opened this issue Jul 30, 2024 · 5 comments
Open

bat as manpager #3053

ukiyocode opened this issue Jul 30, 2024 · 5 comments
Labels
question Further information is requested

Comments

@ukiyocode
Copy link

This is on Linux Mint Willma, with bat installed through homebrew.
When I use the: MANPAGER="sh -c 'col -b | bat -p -l man'" option as described in readme i get weird color codes like: 1mSYNOPSIS0m, but when I simply use MANPAGER="bat -p -l man" everything works fine.

@ukiyocode ukiyocode added the question Further information is requested label Jul 30, 2024
@ukiyocode
Copy link
Author

well mostly fine it seems to add [0m22m or [0m24m in front of left bracket (, but other than that formatting and colors are preserved

@anurag-roy
Copy link

Check out this comment and the whole issue, that might solve your issue.

@eth-p
Copy link
Collaborator

eth-p commented Jul 31, 2024

Additional context for why this is happening:

#2568 (comment)
#2568 (comment)

In summary, newer versions of groff changed to emit ANSI escape sequences by default, and col doesn't handle them properly. The following will work for both older and newer versions of groff:

export MANPAGER="sh -c 'sed -u -e \"s/\\x1B\[[0-9;]*m//g; s/.\\x08//g\" | bat -p -lman'"

@ukiyocode
Copy link
Author

That MANROFFOPT='-c' thing doesn't work for me, but eth-p's suggestion works perfectly, thanks :)

@smprather
Copy link

@eth-p worked for me too. FWIW, I'm on an RHEL8 system with my own terminfo created specifically for MS Terminal (undercurl support, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants