[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Debian]: Re: lesspipe und ~/.tcshrc



Niklas Matthies schrieb am Dienstag, den 11. Mai 1999:

> Ich benutze less mit /usr/bin/lesspipe (LESSOPEN und LESSCLOSE in
> Environment entsprechend gesetzt). Nun habe ich in meiner ~/.tcshrc
> Kommandos eingetragen, welche bestimmte Ausgaben machen, die ich in jeder
> interaktiven Shell sehen moechte.
> 
> Das Problem dabei ist jetzt, dass less das lesspipe-Skript
> anscheinend aus einer interaktiven (tcsh-)Shell heraus aufruft,

Um solchen und ähnlichen Problemen aus dem Wege zu gehen und nebenbei
noch die Möglichkeit zu haben, auch mal ein less ohne lesspipe
aufzurufen, habe ich hier ein kleines Shell-Skript gebaut, das alle
Informationen enthält (also auch die open- und close-Skripte) und
unter dem Namen gless aufgerufen werden kann. Unter anderem umgeht es
das obige Problem mit der Shell...

Tschoeeee

        Roland

-- 
 * roland@spinnaker.de * http://www.spinnaker.de/ *
 PGP: 1024/DD08DD6D   2D E7 CC DE D5 8D 78 BE  3C A0 A4 F1 4B 09 CE AF
#! /bin/sh
#
# $Id: gless,v 1.4 1998/10/26 16:13:47 roland Exp $
#
# This script uses the pager less (version 321 works, don't ask me whether 
# older version work) to display compressed, gzipped, and bzip2ed files.
# In contrast to the original implementation, you can switch between multiple
# files forward and back, because this gless uses the filter mechanism of 
# less to realize uncompressing the files.
#
##########################################################################
#
#   (c) 1997-1998 Roland Rosenfeld <roland@spinnaker.rhein.de>
# 
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License as
#   published by the Free Software Foundation; either version 2 of
#   the License, or (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#   General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
##########################################################################

umask 077

tmpdir=${TMPDIR-/tmp}/gless.$$
mkdir $tmpdir || exit 1
trap "rm -rf $tmpdir; exit" 0 1 2 3 15

#
# create the LESSOPEN file:
#
cat > $tmpdir/open <<EOF
#! /bin/sh
case "\$1" in
    *.Z|*.gz|*.z) gzip -cd \$1 > $tmpdir/plainfile.\$$ 2>/dev/null
          if [ -s $tmpdir/plainfile.\$$ ]; then
                echo $tmpdir/plainfile.\$$
          else
                rm -f $tmpdir/plainfile.\$$
          fi
          ;;
    *.bz) bzip -cd \$1 >$tmpdir/plainfile.\$$ 2>/dev/null
          if [ -s $tmpdir/plainfile.\$$ ]; then
                echo $tmpdir/plainfile.\$$
          else
                rm -f $tmpdir/plainfile.\$$
          fi
          ;;
    *.bz2) bzip2 -cd \$1 >$tmpdir/plainfile.\$$ 2>/dev/null
          if [ -s $tmpdir/plainfile.\$$ ]; then
                echo $tmpdir/plainfile.\$$
          else
                rm -f $tmpdir/plainfile.\$$
          fi
          ;;
    *.F)  freeze -cd \$1 >$tmpdir/plainfile.\$$ 2>/dev/null
          if [ -s $tmpdir/plainfile.\$$ ]; then
                echo $tmpdir/plainfile.\$$
          else
                rm -f $tmpdir/plainfile.\$$
          fi
          ;;
esac
EOF

#
# create the LESSCLOSE file:
#
cat > $tmpdir/close <<EOF
#! /bin/sh
rm -f \$2
EOF

#
# make filters executable:
# 
chmod 700 $tmpdir/open $tmpdir/close

#
# activate filters by setting the environment variables:
#
LESSOPEN="$tmpdir/open %s"
export LESSOPEN
LESSCLOSE="$tmpdir/close %s %s"
export LESSCLOSE

#
# Set the SHELL to /bin/sh, because otherwise less will use the login shell
# (maybe tcsh), which can be awfully slow (tcsh seems to read all it's 
# rc-files):
#
SHELL=/bin/sh
export SHELL

#
# After setting the environment start less:
#
less $*

Reply to: