shell: how to pagination file with code highlight?

Issue

I was checking that you can highlight code with pygmentize like:

pygmentize -g mycodefile

but for large files, I would like the ability to paginate the files like with less or more, but when I try:

pygmentize -g mycodefile | less

The output is not correct, example:

ESC[34mfromESC[39;49;00m ESC[04mESC[36mmodule

How can I paginate a file in shell with code highlight?

Solution

Try

pygmentize -g mycodefile | less -R

so less shows ANSI colour sequences.

Answered By – abligh

Answer Checked By – David Marino (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.