232 lines
6.4 KiB
HTML
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"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
lessfile, lesspipe - "input preprocessor" for less.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>lessfile, lesspipe</B>
|
|
|
|
<A NAME="lbAD"> </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"> </A>
|
|
<H2>USAGE</H2>
|
|
|
|
Just put one of the following two commands in your login script (e.g.
|
|
~/.bash_profile):
|
|
<P>
|
|
|
|
<BR> eval "$(lessfile)"
|
|
<P>
|
|
|
|
or
|
|
<P>
|
|
|
|
<BR> eval "$(lesspipe)"
|
|
<A NAME="lbAF"> </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> *.a
|
|
<BR> *.arj
|
|
<BR> *.tar.bz2
|
|
<BR> *.bz
|
|
<BR> *.bz2
|
|
<BR> *.deb, *.udeb, *.ddeb
|
|
<BR> *.doc
|
|
<BR> *.egg
|
|
<BR> *.gif, *.jpeg, *.jpg, *.pcd, *.png, *.tga, *.tiff, *.tif
|
|
<BR> *.iso, *.raw, *.bin
|
|
<BR> *.lha, *.lzh
|
|
<BR> *.tar.lz, *.tlz
|
|
<BR> *.lz
|
|
<BR> *.7z
|
|
<BR> *.pdf
|
|
<BR> *.rar, *.r[0-9][0-9]
|
|
<BR> *.rpm
|
|
<BR> *.tar.gz, *.tgz, *.tar.z, *.tar.dz
|
|
<BR> *.gz, *.z, *.dz
|
|
<BR> *.tar
|
|
<BR> *.tar.xz, *.xz
|
|
<BR> *.whl
|
|
<BR> *.jar, *.war, *.xpi, *.zip
|
|
<BR> *.zoo
|
|
|
|
<A NAME="lbAG"> </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> #!/bin/sh
|
|
<P>
|
|
<BR> case "$1" in
|
|
<BR> *.extension)
|
|
<BR> extension-handler "$1"
|
|
<BR> ;;
|
|
<BR> *)
|
|
<BR> # We don't handle this format.
|
|
<BR> exit 1
|
|
<BR> esac
|
|
<P>
|
|
<BR> # No further processing by lesspipe necessary
|
|
<BR> exit 0
|
|
|
|
<P>
|
|
<A NAME="lbAH"> </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"> </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> if [ -z "$PS1" ]; then
|
|
<BR> exit
|
|
<BR> 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"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<A HREF="/cgi-bin/man/man2html?1+less">less</A>(1)
|
|
<A NAME="lbAK"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
This manual page was written by Thomas Schoepf <<A HREF="mailto:schoepf@debian.org">schoepf@debian.org</A>>,
|
|
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 <<A HREF="mailto:torin@daft.com">torin@daft.com</A>>.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </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>
|