I have installed python-pygments
and using it for syntax highlighting with less
as described by mankoff here
I put a function in my .bashrc
cless () {
pygmentize -f terminal "$1" | less -R
}
it is enabling syntax highlighting with less
. But when I am going to open a file like /etc/fstab
or /etc/apt/apt.conf
a error saying
Error: no lexer for filename '/etc/apt/apt.conf' found
I found option to show pygmentize
the lexer with -l
at this manpage. But what will be the appropriate lexer for such files? and how to use it?
Buried in
pygmentize --help
:Simply change your code to:
To have syntax highlight on Ubuntu/Debian first install
Then you may want to add this two environment variables to
~/.bashrc
Tip: Also notice v on
less
open the file on default editor (defined byselect-editor
command) that maybe have syntax highlight. Here it is how to add compatibility to a lot of file types innano
.Reference