Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: clear terminal after display of less, <, and apropos
- X-seq: zsh-users 1874
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: Roland Jesse <jesse@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxxxxxxx
- Subject: Re: clear terminal after display of less, <, and apropos
- Date: Thu, 15 Oct 1998 11:09:35 -0700
- In-reply-to: <9810151322.AA14146@xxxxxxxxxxxxxxxxxx>
- References: <19981014233316.A613@xxxxxxxxxxxxxxxxxxx> <981014182516.ZM20780@xxxxxxxxxxxxxxxxxxxxxxx> <19981015121103.A20207@xxxxxxxx> <9810151322.AA14146@xxxxxxxxxxxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author