#! /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?*) 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` export TERM case $TERM in *256*) if (infocmp screen-256color-bce > /dev/null 2>&1) ; then SCREEN_COLOR="-256color" export SCREEN_COLOR fi ;; esac