Linux distributions nowadays have a default
LESSOPEN set to
/usr/bin/lesspipe which allows one to easily inspect e.g. zipped files or PDF files.
Now I wanted to see whether I can add syntax highlighting to less. This is easily accomplished with source-highlight. I used
LESSOPEN="| /usr/bin/source-highlight -i %s -q -f esc" and it works fine.
But now the problem becomes: How do I get the behavior of both lesspipe and source-highlight? Simply appending one after the other doesn't work:
$ export LESSOPEN="| /usr/bin/lesspipe %s | /usr/bin/source-highlight -i %s -q -f esc" $ less foo Invalid LESSOPEN variable
It also doesn't make sense so this is not really surprising.
Is it possible to set this up without writing elaborate scripts? The best case would be to have chaining, i.e., provide syntax highlight for a zipped file as well.