These pages for lesspipe are no longer maintained, please visit lesspipe.org
Displaying more with less (Version 2.21 Nov 24, 2025)
lesspipe.sh is an input filter for the pager
less as described in less's man page. The script runs as a bash or zsh
script and allows you to view files with binary content,
compressed files, archives and files contained in archives. It supports many formats (both as plain and compressed files using gzip, bzip2 and other pack programs).
Details can be found in the README.md file.
Syntax highlighting of source code is possible through several programs
such as nvimpager, bat, pygmentize or source-highlight.
The scripts code2color and vimcolor are also usable derived from older programs found in the internet and tailored for the use within lesspipe. They are found now on separate github repositories.
Syntax highlighting and other methods of colorizing the output are only
activated if the environment variable
LESS is existing and contains the option -R or less is called with -R.
This guarantees, that instead of literal escape sequences
colors are displayed. The detection of the -R presence at runtime is
rather dependent on the operating system and may not work in all cases.
The script lesspipe.sh needs a lot of helper programs that may or may not be
installed on your computer.
The lesspipe.sh from version 2 on
interactively checks for the existence of these helper programs.
The script that does the colorization by default can be replaced by setting
the LESSCOLORIZER env variable to the desired colorizer.
Starting with version 2.01 tab completion of files within archives is possible.
A colon or equal sign after the archive name followed by a tab key press
engages the completion mechanism (bash and zsh) if properly installed.
That requires the script lesscomplete to be executable and to be found in $PATH and for zsh the script called _less in one of the $fpath directories. For bash the less script needs to be installed in /etc/bashcompletion.d/. Both scripts get generated during the lesspipe_installation using make install.
The lesspipe.sh filtering can be replaced or enhanced by a user defined
program. Such a program has to be called either .lessfilter (and be placed in
the users home directory), or lessfilter (and be accessible from a directory
mentioned in the environment variable $PATH).
That program has to be executable and has to end with an exit code 0, if the
filtering was done within that script. Otherwise, a nonzero exit code means
the filtering is left to lesspipe.sh.
This mechanism can be used to add filtering for new formats or e.g. inhibit
filtering for certain file types.
To get support for newer file types an additional magic file (for use in the
file command, e.g. in ~/.magic) might have to be created. In that case the
environment variable MAGIC has to be set and has to contain both the system
magic file and your personal one. Example:
MAGIC='/usr/share/file/magic:/Users/myaccount/.magic'
export MAGIC
Download
The tarball lesspipe.tar.gz is available both from
lesspipe.org as well as from
GitHub (branch lesspipe)
The following files are available separately for download from lesspipe.org
(all contained in the tarball):
Older versions can be downloaded from the archive as well.
Documentation
Here is an incomplete list of old articles that did describe lesspipe.sh
german.txt article about the usage of lesspipe(in german, not up to date)
Linux Magazin 01/2001
CERN Computing Newsletter 01/2002
Linux User 04/2002 (in german)
Linux User 07/2022 (in german)
The zip file of the latest released version and other files can be retrieved from github as well.
|