‘less’ on steroids
During the writing about XMonad i got this idea: why not filter source code through colouring program to get a colourful view, and why not do it automatically? Turns out less authors already had this idea🙂 ‘less’ allows to apply arbitrary filter through the usage of LESSPIPE environmental variable. See man less(1) for details.
There is already another utility for similar purpose: lesspipe. According to the project homepage it can handle various archive formats as well as source code. However, source code is filtered through utility code2color, which I’m not satisfied with. First of all, it doesn’t work as supposed to. For some reason it isn’t called and I really doesn’t feel like debugging the utility. There are no error messages, so I’m doesn’t really know why. Secondly I dislike it’s design:
- It’s a huge, single file with ~3300 lines.
- It doesn’t use any external libraries besides getopt. This means it handles all code coloring itself. This issue also affects #1
- As a result, the number of supported languages is small: only 21. This package available on Hackage currently supports 56. Including my favorite, Haskell🙂
I decided to write my own replacement for lesspipe. I’m going to post some details about this project soon. Stay tuned!