File: LESSOPEN

package info (click to toggle)
jless 332iso240-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,228 kB
  • ctags: 1,482
  • sloc: ansic: 16,120; sh: 190; makefile: 142; awk: 7
file content (31 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From the man page:
       You  may  define an "input preprocessor" for less.  Before
       less opens a file, it first gives your input  preprocessor
       a  chance  to  modify the way the contents of the file are
       displayed.

What this means is that less(1) can automatically open up tar files,
uncompress gzipped files, and even display something reasonable for
graphics files.

You just need to put the following in your
.zlogin/.login/.bash_profile/whatever:

eval $(lesspipe)
or
eval $(lessfile)

lesspipe will toss the contents/info on stdout and less will read them
as they come across.  This means that you don't have to wait for the
decoding to finish before less shows you the file.  This also means that
you'll 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.

lessfile will toss the contents/info on a file which less will then
read.  After you're done, lessfile 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.

If you have any questions, send me e-mail at <torin@daft.com>.
Mentioning less in the subject line will help.