when I read a file in Linux with the command 'less' or 'more', how can I get the content in colors?
feedback
|
migrated from stackoverflow.com Mar 9 '10 at 10:50
This question came from our site for professional and enthusiast programmers.
|
You can utilize the power of pygmentize with less - automatically! (No need to pipe by hand.) Write a file ~/.lessfilter
In your .bashrc add
Tested on debian. The idea comes from here Using Pygments with less. | |||
|
feedback
|
|
| |||||
feedback
|
|
I got the answer in another post: Less and Grep - Color
| |||||
feedback
|
|
Try the following:
| |||||
feedback
|
|
You didn't say what this color should mean, e.g. what should the colors be for a text file? If what you want is syntax highlighting for source code, you need a source code highlighter. I sometimes use pygmentize like this
or
There are other highlighters around. This is pretty fast. If you don't mind firing up
or alternatively see churnd's answer. | |||
|
feedback
|