2009-01-03 14:15:00 -06:00
|
|
|
#! /bin/sh
|
|
|
|
|
2009-01-02 18:37:27 -05:00
|
|
|
# terminal fallback stuff
|
2009-01-03 14:15:00 -06:00
|
|
|
fix_term ()
|
2009-01-02 18:37:27 -05:00
|
|
|
{
|
2009-01-23 15:11:53 -06:00
|
|
|
# we were requested to go on screen and we are on a mac
|
2009-01-14 22:15:09 -05:00
|
|
|
if ( infocmp $1 >/dev/null 2>&1 ) ; then
|
2009-01-02 18:37:27 -05:00
|
|
|
echo $1
|
|
|
|
else
|
|
|
|
case $1 in
|
2009-01-23 14:50:11 -06:00
|
|
|
rxvt|xterm?*|kterm|putty|screen)
|
2009-01-02 18:37:27 -05:00
|
|
|
fix_term xterm
|
|
|
|
;;
|
|
|
|
*rxvt?*|Eterm|aterm)
|
|
|
|
fix_term rxvt
|
|
|
|
;;
|
|
|
|
mlterm)
|
|
|
|
fix_term kterm
|
|
|
|
;;
|
2009-01-13 17:15:41 -05:00
|
|
|
screen-256colors-bce)
|
|
|
|
fix_term screen-256colors
|
|
|
|
;;
|
|
|
|
screen-256colors)
|
2009-01-14 22:15:09 -05:00
|
|
|
if ( infocmp xterm-256colors >/dev/null 2>&1 ) ; then
|
2009-01-13 17:15:41 -05:00
|
|
|
fix_term xterm-256colors
|
|
|
|
else
|
|
|
|
fix_term screen
|
|
|
|
fi
|
|
|
|
;;
|
2009-01-02 18:37:27 -05:00
|
|
|
screen?*)
|
|
|
|
fix_term screen
|
|
|
|
;;
|
2009-02-24 07:42:25 +00:00
|
|
|
putty-vt100)
|
|
|
|
echo "vt100"
|
|
|
|
;;
|
|
|
|
putty-256color)
|
|
|
|
fix_term xterm-256color
|
2009-01-02 18:37:27 -05:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "vt100"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# sorta hacky, but I cannot find a better way to do this :/
|
2009-01-03 14:15:00 -06:00
|
|
|
fix_terminfo_db ()
|
2009-01-02 18:37:27 -05:00
|
|
|
{
|
2009-01-16 13:53:32 -06:00
|
|
|
if [ -d "$1" ] && [ `command -v infocmp 2>/dev/null` = "$1/bin/infocmp" ] ; then
|
2009-01-03 14:15:00 -06:00
|
|
|
TERMINFO="$1/share/terminfo"
|
|
|
|
export TERMINFO
|
2009-01-02 18:37:27 -05:00
|
|
|
fi
|
|
|
|
}
|
2009-01-03 14:15:00 -06:00
|
|
|
|
2009-01-23 14:49:04 -06:00
|
|
|
if ( command -v infocmp >/dev/null 2>&1 ) ; then
|
|
|
|
# terminal surgery
|
|
|
|
case `uname -s` in
|
|
|
|
Interix)
|
|
|
|
fix_terminfo_db "/usr/local"
|
|
|
|
;;
|
|
|
|
SunOS)
|
|
|
|
fix_terminfo_db "/opt/csw"
|
|
|
|
;;
|
|
|
|
Darwin)
|
|
|
|
fix_terminfo_db "/opt/local"
|
|
|
|
;;
|
|
|
|
esac
|
2009-01-02 18:37:27 -05:00
|
|
|
|
2009-01-23 14:49:04 -06:00
|
|
|
TERM=`fix_term $TERM`
|
2009-01-02 18:37:27 -05:00
|
|
|
|
2009-01-23 14:49:04 -06:00
|
|
|
# I am sorry to hear that you are running an
|
|
|
|
# xterm that has no colors (I am looking at you solaris)
|
|
|
|
if [ $TERM = xterm ] && ( command -v tput >/dev/null 2>&1 ) && [ `tput -T xterm colors` = -1 ] ; then
|
|
|
|
# lets see what we can do about your terrible term
|
|
|
|
TERM=`fix_term xterm-color`
|
|
|
|
fi
|
2009-01-02 18:37:27 -05:00
|
|
|
|
2009-01-23 14:49:04 -06:00
|
|
|
export TERM
|
2009-01-02 18:37:27 -05:00
|
|
|
|
2009-01-23 14:49:04 -06:00
|
|
|
case $TERM in
|
|
|
|
*256*)
|
2009-01-23 15:11:53 -06:00
|
|
|
alias screen="screen -T `fix_term xterm-256color`"
|
2009-01-23 14:49:04 -06:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|