lesspipe

Langue: en

Autres versions - même langue

Version: 57757 (mandriva - 22/10/07)

Section: 1 (Commandes utilisateur)

NAME

lesspipe.sh - a filter for less

SYNOPSIS

lesspipe.sh [FILE[s]]...

DESCRIPTION

Usually 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 or 7-zip) files. For files containing archives and directories, a table of contents will be displayed (e.g tar, ar rar, rpm and deb formats). Other supported formats include nroff, pdf, ps, dvi, shared library, word, debian package, html, mp3, iso images, MacOSX bom and archive formats and perl storable data. This does require additional helper programs being installed.

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 name.

FILTER ACTIVATION

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 LESSOPEN directly:

eval `lesspipe.sh`

Having set the environment variable as described above, less will then display textual information for a wide range of file formats.

ADVANCED USAGE

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

less archive_file:contained_file

or even

less super_archive:archive_file:contained_file

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 | less

can be used instead of unsetting the environment variable LESSOPEN

SYNTAX HIGHLIGHTING (experimental)

The filter is able to do syntax highlighting for the languages ada, asm, awk, c, c++, groff, html, xml, java, javascript, lisp, m4, make, pascal, patch, perl, povray, python, ruby shellscript and sql. The choice of colors is just a first guess (proof of concept) and still needs refinements.

ATTENTION: Syntax highlighting is only activated, if the environment variable LESS exists and contains the option -R or -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:

Makefile .pas .patch .diff .pm .pl .pod .pov .py .rb .sh .sql

AUTHOR

Written by Wolfgang Friebel

REPORTING BUGS

Report bugs to <Wolfgang.Friebel AT desy.de>. Copyright © 2005 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.

SEE ALSO

less(1)

A description of lesspipe.sh is also contained in the file english.txt contained in the source code package