#! /bin/sh # terminal fallback stuff fix_term () { if (infocmp $1 > /dev/null 2>&1) ; then echo $1 else case $1 in rxvt|xterm?*|kterm|putty) fix_term xterm ;; *rxvt?*|Eterm|aterm) fix_term rxvt ;; mlterm) fix_term kterm ;; screen-256colors-bce) fix_term screen-256colors ;; screen-256colors) if (infocmp xterm-256colors &> /dev/null) ; then fix_term xterm-256colors else fix_term screen fi ;; screen?*) fix_term screen ;; putty?*) fix_term putty ;; *) echo "vt100" ;; esac fi } # sorta hacky, but I cannot find a better way to do this :/ fix_terminfo_db () { if [ `command -v infocmp 2>/dev/null` = "$1/bin/infocmp" ] ; then TERMINFO="$1/share/terminfo" export TERMINFO fi } # 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 TERM=`fix_term $TERM` # 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 export TERM case $TERM in *256*) SCREEN_TERM=$(fix_term screen-256color-bce) alias screen="screen -T ${SCREEN_TERM}" ;; esac