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

Pygmentize doesn't colorize when piped through Less #67

Closed
frossm opened this issue May 31, 2020 · 2 comments
Closed

Pygmentize doesn't colorize when piped through Less #67

frossm opened this issue May 31, 2020 · 2 comments

Comments

@frossm
Copy link

frossm commented May 31, 2020

Hello fellow lessers,

I'm having a Windows 10 issue with colorization I'm hoping this group can help me. I've decided to use pygmentize to colorize files in less.

Here is an example using pygmentize on the python script "texi2html.py" which is included in my python distribution.

The command:
c:\apps\python\scripts\pygmentize texi2html.py

produces colored output.

The command:
c:\apps\python\script\pygmentize texi2html.py | less -R

paginates the page, but without the colors.

This issue holds true for Perl files as well...it's not that specific file that has issues.

Using less version 562 Beta. I do not have a LESS or LESSOPEN environment set for this test. I may be doing something incorrectly, but I'm not sure what it could be. Does anyone else have this working in windows?

Any pointers in the right direction would be appreciated.

Michael

@rivy
Copy link

rivy commented Oct 5, 2020

I don't know pygmentize, but lots of applications strip or don't generate color when STDOUT is redirected. Most have a --color option to specify the color output behavior. The usual option semantics are that --color=auto, which is the usual default, has colorized output for un-redirected STDOUT and non-colorized output for redirected STDOUT. Alternatively, --color=always has colorized output no matter the status of STDOUT redirection. So, ls --color=always | less -R should be colorized.

@gwsw
Copy link
Owner

gwsw commented Jan 3, 2021

This seems to be more a question about pygmentize rather than about less.

@gwsw gwsw closed this as completed Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants