From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14225 invoked from network); 15 Oct 1998 18:27:40 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 15 Oct 1998 18:27:40 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id OAA14544; Thu, 15 Oct 1998 14:10:34 -0400 (EDT) Resent-Date: Thu, 15 Oct 1998 14:06:46 -0400 (EDT) From: "Bart Schaefer" Message-Id: <981015110935.ZM24779@candle.brasslantern.com> Date: Thu, 15 Oct 1998 11:09:35 -0700 In-Reply-To: <9810151322.AA14146@ezdzit.zko.dec.com> Comments: In reply to Paul Lew "Re: clear terminal after display of less, <, and apropos" (Oct 15, 9:22am) References: <19981014233316.A613@cs.uni-magdeburg.de> <981014182516.ZM20780@candle.brasslantern.com> <19981015121103.A20207@kappa.ro> <9810151322.AA14146@ezdzit.zko.dec.com> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Roland Jesse , zsh-users@math.gatech.edu Subject: Re: clear terminal after display of less, <, and apropos MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"3zr-f2.0.qW3.scZ9s"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1874 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Oct 15, 9:22am, Paul Lew wrote: } Subject: Re: clear terminal after display of less, <, and apropos } } function notite { } TERMCAP=$(printenv TERMCAP | sed 's/:ti=[^:]*//; s/:te=[^:]*//;') } } Unfortunately, that doesn't work for programs that use the terminfo database. For example, on my RedHat Linux 4.2 system, changing TERMCAP affects "less" but does not affect "vim". The only way to be sure of getting the effect is to change either the terminal type or both the termcap and terminfo definitions for it. However -- and to keep this discussion relevant to zsh-users -- I just remembered a little zsh script called "fixinfo" that I wrote long ago to clean up a braindamaged terminfo database. I had to tweak it a bit because, contrary to the documentation, my "captoinfo" program ignores $TERMCAP and always process the entire /etc/termcap file, unles you give it an explicit file name. With the above function and the one below: notite ; fixinfo ${TERM}-notite should deal with everything. I wrote this before zsh had getopts, so there's other modernizing that could be done. #! /usr/local/bin/zsh -f function fixinfo() { # Temporarily fix up a bad terminfo database # This is designed to make a terminfo entry match the termcap entry, # or to add a missing terminfo entry by compiling the termcap entry. # It requires "tic" and "captoinfo" e.g. from the ncurses package. # # If the termcap entry is correct but terminfo is wrong or missing: # fixinfo # If the /etc/termcap entry is wrong but $TERMCAP is correct, use: # fixinfo newtermname # where "newtermname" is a name that doesn't appear in /etc/termcap, so # ill-behaved programs can't accidentally get the old description. # # This is intended to be an autoloaded function. If you can't autoload # it, or want to use it from some shell other than zsh (still requires # that zsh be installed) then use: # eval `fixinfo` # or: # eval `fixinfo newtermname` # # Add the -f option to forcibly replace descriptions previously written # by this program. [[ -n "${TERMCAP:-}" ]] || { echo TERMCAP not set 1>&2; return 1 } local force=false newterm=$TERM while (($# > 0)) do case $1 in -f) force=true;; *-help) echo "Usage: fixinfo [newname [newname ...]]" 2>&1 return 0 ;; *) if [[ ! -f "$TERMCAP" ]] then TERMCAP=$(echo "$TERMCAP" | sed -e 's/\\$//' -e "s/^/$1|/") newterm="$1" fi ;; esac shift done TERMINFO=${TERMINFO:-/tmp/tinfo-$EUID} [[ -d $TERMINFO ]] || mkdir -p $TERMINFO || return 1 [[ -w $TERMINFO ]] || return 1 export TERMCAP TERMINFO if [[ -f $TERMINFO/$newterm[1]/$newterm ]] then export TERM="$newterm" $force || return 0 fi if [[ -f "$TERMCAP" ]] then tic =(captoinfo) else tic =(captoinfo =(<<<"$TERMCAP")) # Requires 3.0.something for <<< fi export TERM="$newterm" [[ -t 1 ]] || echo export TERM=\""$newterm"\"\; export TERMCAP=\""$TERMCAP"\" return 0 } -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com