Manual Reference Pages - LESSPIPE (1)
lesspipe.sh - a filter for less
lesspipe.sh is called as an input filter to
less With the help of that filter
less will display the uncompressed contents of compressed (gzip, bzip2, compress,
rar, 7-zip, lzip, xz or lzma) files.
For files containing archives and directories, a table of contents
will be displayed (e.g tar, ar, rar, jar, rpm and deb formats). Other supported
formats include nroff, pdf, ps, dvi, shared library, MS word,
OASIS (e.g. Openoffice), NetCDF,
html, mp3, jpg, png, iso images, MacOSX bom, plist and archive formats, perl
storable data and gpg encrypted files.
This does require additional helper programs being installed.
If at configure
time support for the ENV variable LESS_ADVANCED_PREPROCESSOR was included then
files with mostly ASCII text such as html, ps, rtf and files with
alternate character encoding remain normally unprocessed (see below)
The filter does not only display the above mentioned file formats,
but can also be applied recursively up to a depth of 6 where applying a
decompression algorithm counts as a separate level.
In a few rare cases the
file command does not recognize the correct format (especially with nroff).
In such cases filtering can be suppressed by a trailing colon on the file
If the file command reports text with UTF-8, ISO-8859-1 or UTF-16 encoded
characters then the text will be transformed using iconv into the default
encoding. This does assume iconv has the right default which can be wrong
in some situations.
To suppress informal messages in the first line of the filter output the
LESSQUIET can be set to a nonempty value.
The filter is called from
less provided the environment variable
LESSOPEN is set properly. For the shells csh and tcsh the command
setenv LESSOPEN "|lesspipe.sh %s"
should be used, for other shells the command
LESSOPEN="|lesspipe.sh %s"; export LESSOPEN
does activate the filter for less. Use the fully qualified path, if
lesspipe.sh is not in the search path. The command to set
LESSOPEN can also be displayed by calling
lesspipe.sh without arguments. This can even be used to set
Having set the environment variable as described above,
less will then display textual information for a wide range of file formats.
This version of
lesspipe.sh allows you to view individual files contained in a file archive, which itself
may even be contained in another archive.
The notation for viewing files in multifile archives is
To display a file in raw format, a colon (:) has to be appended
to the file name.
To suppress the decompression of files two colons have to be appended. This
does apply as well to the last file in the colon separated chain of file
names as described above.
To display files without engaging
lesspipe.sh temporarily, the command
cat filename |
can be used instead of unsetting the environment variable
If the ENV variable LESS_ADVANCED_PREPROCESSOR is respected by lesspipe.sh
then files containing mostly ASCII text get displayed unmodified. To activate
filtering for such formats the contents of
LESS_ADVANCED_PREPROCESSOR has to be set to an non empty value.
The filter is able to do syntax highlighting for
m4, make, pascal, patch, perl, povray, python, ruby shellscript and sql by
using code2color as the colorizing program. A different colorizer can be called
within code2color by setting the ENV variable
LESSCOLORIZER to the name of an alternative (currently only pygmentize allowed). Therefore
code2color is always needed for syntax highlighting.
ATTENTION: Syntax highlighting is only activated, if the environment variable
LESS exists and contains the option
-r or less is called with one
of these options. This guarantees, that instead of literal escape sequences,
colors are displayed. The detection of the
-r/-R presence at runtime is
rather dependent on the operating system and may not work in all cases.
Putting the option in the
LESS environment variable is guaranteed to work.
As syntax highlighting is rather resource intense, it can be switched off by
appending a colon after the file name, if the output was colorful. If the
wrong language was chosen for syntax highlighting, then another one can be
forced by appending a colon and a suffix to the file name.
The following suffixes are recognized (works with code2color only):
Makefile .pas .patch .diff .pm .pl .pod .pov .py .rb .sh .sql
When the conditions for syntax highlighting are met directory listings and
listings of tar file contents get colorized as well.
Written by Wolfgang Friebel
Report bugs to <Wolfgang.Friebel AT desy.de>.
Copyright © 2005-2015 Wolfgang Friebel
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
A description of
lesspipe.sh is also contained in the file README contained in the source code package
|lesspipe.sh ||LESSPIPE.SH (1) ||Oct 2011 |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.