Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: clear terminal after display of less, <, and apropos

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
	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))
    case $1 in
    -f) force=true;;
        echo "Usage: fixinfo [newname [newname ...]]" 2>&1
        return 0
        if [[ ! -f "$TERMCAP" ]]
            TERMCAP=$(echo "$TERMCAP" | sed -e 's/\\$//' -e "s/^/$1|/")
[[ -d $TERMINFO ]] || mkdir -p $TERMINFO || return 1
[[ -w $TERMINFO ]] || return 1
if [[ -f $TERMINFO/$newterm[1]/$newterm ]]
    export TERM="$newterm"
    $force || return 0
if [[ -f "$TERMCAP" ]]
then tic =(captoinfo)
else tic =(captoinfo =(<<<"$TERMCAP"))	# Requires 3.0.something for <<<
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