3

I've seen several programmers using ./lessfilter filtes for preprocessing files before being feeded to less. However my less doesn't seem to recognize my .lessfilter file in ~. What am I doing wrong? My manpage of less doesn't mention it.

$ less —version
less 481 (POSIX regular expressions)
Copyright (C) 1984-2015  Mark Nudelman
hgiesel
  • 5,430
  • 2
  • 29
  • 56
  • 2
    Read the section "input preprocessor" in the man page, especially about the `LESSOPEN` environment variable. – 4ae1e1 Nov 24 '15 at 22:11
  • 1
    It is mentioned in the man page of lesspipe on Debian: http://unix.com/man-page/linux/1/lesspipe – xuhdev Sep 24 '16 at 07:31
  • 1
    There is a nice example of how to use `.lessfilter` on SO: https://stackoverflow.com/a/38494086/205696. The example is for macOS but works fine on Linux for me. Spoiler alert, `.lessfilter` can be called what-ever you want. – dotnetCarpenter Feb 01 '21 at 01:04
  • There is also an excellent answer https://superuser.com/a/71593/279100 of using GNU Source-highlight with `LESSOPEN` environment variable. – dotnetCarpenter Feb 16 '23 at 15:17

1 Answers1

5

Noting the comment: the less manual page does not mention .lessfilter, and it is not a feature of less (see source code).

Instead, it is used in some examples which set the LESSOPEN variable to a script. Here are a few places where that is mentioned:

So you may have seen this feature in a Fedora package, or seen someone using it based on the several places it was described, but it is not generally part of less.

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • It is mentioned in the man page of `lesspipe` on Debian: http://www.unix.com/man-page/linux/1/lesspipe/ – xuhdev Sep 24 '16 at 07:30