man-pages/man1/lesspipe.1.html
2021-03-31 01:06:50 +01:00

232 lines
6.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of LESSOPEN</TITLE>
</HEAD><BODY>
<H1>LESSOPEN</H1>
Section: User Commands (1)<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
lessfile, lesspipe - &quot;input preprocessor&quot; for less.
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>lessfile, lesspipe</B>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
This manual page documents briefly the
<I>lessfile</I>,
and
<I>lesspipe</I>
commands.
This manual page was written for the Debian GNU/Linux distribution
because the input preprocessor scripts are provided by Debian GNU/Linux and
are not part of the original program.
<P>
<I>lessfile</I>
and
<I>lesspipe</I>
are programs that can be used to modify the way the contents of a file are
displayed in
<I>less.</I>
What this means is that
<I>less</I>
can automatically open
up tar files, uncompress gzipped files, and even display something reasonable
for graphics files.
<P>
<I>lesspipe</I>
will toss the contents/info on STDOUT and
<I>less</I>
will read them
as they come across. This means that you do not have to wait for the
decoding to finish before less shows you the file. This also means that
you will get a 'byte N' instead of an N% as your file position. You can
seek to the end and back to get the N% but that means you have to wait
for the pipe to finish.
<P>
<I>lessfile</I>
will toss the contents/info on a file which
<I>less</I>
will then
read. After you are done,
<I>lessfile</I>
will then delete the file. This means that the process has to finish before
you see it, but you get nice percentages (N%) up front.
<A NAME="lbAE">&nbsp;</A>
<H2>USAGE</H2>
Just put one of the following two commands in your login script (e.g.
~/.bash_profile):
<P>
<BR>&nbsp;&nbsp;eval&nbsp;&quot;$(lessfile)&quot;
<P>
or
<P>
<BR>&nbsp;&nbsp;eval&nbsp;&quot;$(lesspipe)&quot;
<A NAME="lbAF">&nbsp;</A>
<H2>FILE TYPE RECOGNITION</H2>
File types are recognized by their extensions.
This is a list of currently supported extensions
(grouped by the programs that handle them):
<P>
<BR>&nbsp;&nbsp;*.a
<BR>&nbsp;&nbsp;*.arj
<BR>&nbsp;&nbsp;*.tar.bz2
<BR>&nbsp;&nbsp;*.bz
<BR>&nbsp;&nbsp;*.bz2
<BR>&nbsp;&nbsp;*.deb,&nbsp;*.udeb,&nbsp;*.ddeb
<BR>&nbsp;&nbsp;*.doc
<BR>&nbsp;&nbsp;*.egg
<BR>&nbsp;&nbsp;*.gif,&nbsp;*.jpeg,&nbsp;*.jpg,&nbsp;*.pcd,&nbsp;*.png,&nbsp;*.tga,&nbsp;*.tiff,&nbsp;*.tif
<BR>&nbsp;&nbsp;*.iso,&nbsp;*.raw,&nbsp;*.bin
<BR>&nbsp;&nbsp;*.lha,&nbsp;*.lzh
<BR>&nbsp;&nbsp;*.tar.lz,&nbsp;*.tlz
<BR>&nbsp;&nbsp;*.lz
<BR>&nbsp;&nbsp;*.7z
<BR>&nbsp;&nbsp;*.pdf
<BR>&nbsp;&nbsp;*.rar,&nbsp;*.r[0-9][0-9]
<BR>&nbsp;&nbsp;*.rpm
<BR>&nbsp;&nbsp;*.tar.gz,&nbsp;*.tgz,&nbsp;*.tar.z,&nbsp;*.tar.dz
<BR>&nbsp;&nbsp;*.gz,&nbsp;*.z,&nbsp;*.dz
<BR>&nbsp;&nbsp;*.tar
<BR>&nbsp;&nbsp;*.tar.xz,&nbsp;*.xz
<BR>&nbsp;&nbsp;*.whl
<BR>&nbsp;&nbsp;*.jar,&nbsp;*.war,&nbsp;*.xpi,&nbsp;*.zip
<BR>&nbsp;&nbsp;*.zoo
<A NAME="lbAG">&nbsp;</A>
<H2>USER DEFINED FILTERS</H2>
It is possible to extend and overwrite the default
<I>lesspipe</I>
and
<I>lessfile</I>
input processor if you have specialized requirements. Create an executable
program with the name
<I>.lessfilter</I>
and put it into your home directory. This can be a shell script or a binary
program.
<P>
<P>
It is important that this program returns the correct exit code: return 0 if
your filter handles the input, return 1 if the standard
<I>lesspipe/lessfile</I>
filter should handle the input.
<P>
<P>
Here is an example script:
<P>
<BR>&nbsp;&nbsp;#!/bin/sh
<P>
<BR>&nbsp;&nbsp;case&nbsp;&quot;$1&quot;&nbsp;in
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*.extension)
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;extension-handler&nbsp;&quot;$1&quot;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*)
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;We&nbsp;don't&nbsp;handle&nbsp;this&nbsp;format.
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit&nbsp;1
<BR>&nbsp;&nbsp;esac
<P>
<BR>&nbsp;&nbsp;#&nbsp;No&nbsp;further&nbsp;processing&nbsp;by&nbsp;lesspipe&nbsp;necessary
<BR>&nbsp;&nbsp;exit&nbsp;0
<P>
<A NAME="lbAH">&nbsp;</A>
<H2>FILES</H2>
<DL COMPACT>
<DT id="1"><I>~/.lessfilter</I>
<DD>
Executable file that can do user defined processing. See section USER DEFINED
FILTERS for more information.
</DL>
<A NAME="lbAI">&nbsp;</A>
<H2>BUGS</H2>
<P>
Sometimes, less does not display the contents file you want to view but output
that is produced by your login scripts (~/.bashrc or ~/.bash_profile). This
happens because less uses your current shell to run the lesspipe filter. Bash
first looks for the variable $BASH_ENV in the environment expands its value
and uses the expanded value as the name of a file to read and execute. If
this file produces any output less will display this. A way to solve this
problem is to put the following lines on the top of your login script that
produces output:
<P>
<BR>&nbsp;&nbsp;if&nbsp;[&nbsp;-z&nbsp;&quot;$PS1&quot;&nbsp;];&nbsp;then
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit
<BR>&nbsp;&nbsp;fi
<P>
This tests whether the prompt variable $PS1 is set and if it isn't (which is
the case for non-interactive shells) it will exit the script.
<A NAME="lbAJ">&nbsp;</A>
<H2>SEE ALSO</H2>
<A HREF="/cgi-bin/man/man2html?1+less">less</A>(1)
<A NAME="lbAK">&nbsp;</A>
<H2>AUTHOR</H2>
This manual page was written by Thomas Schoepf &lt;<A HREF="mailto:schoepf@debian.org">schoepf@debian.org</A>&gt;,
for the Debian GNU/Linux system (but may be used by others). Most of the
text was copied from a description written by Darren Stalder &lt;<A HREF="mailto:torin@daft.com">torin@daft.com</A>&gt;.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="2"><A HREF="#lbAB">NAME</A><DD>
<DT id="3"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="4"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="5"><A HREF="#lbAE">USAGE</A><DD>
<DT id="6"><A HREF="#lbAF">FILE TYPE RECOGNITION</A><DD>
<DT id="7"><A HREF="#lbAG">USER DEFINED FILTERS</A><DD>
<DT id="8"><A HREF="#lbAH">FILES</A><DD>
<DT id="9"><A HREF="#lbAI">BUGS</A><DD>
<DT id="10"><A HREF="#lbAJ">SEE ALSO</A><DD>
<DT id="11"><A HREF="#lbAK">AUTHOR</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:18 GMT, March 31, 2021
</BODY>
</HTML>