Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

Buried in pygmentize --help:

If -g is passed, attempt to guess the lexer from the file contents, or pass through as plain text if this fails (this can work for stdin).

Simply change your code to:

cless () {
    pygmentize -gf terminal "$1" | less -R
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.