#! /bin/sh # terminal fallback stuff fix_term () { # we were requested to go on screen and we are on a mac if infocmp $1 >/dev/null 2>&1 ; then echo $1 else case $1 in xterm-termite) fix_term xterm-256colors ;; rxvt|xterm?*|kterm|putty|screen) 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 2>&1 ; then fix_term xterm-256colors else fix_term screen fi ;; screen?*) fix_term screen ;; putty-vt100) echo "vt100" ;; putty-256color) fix_term xterm-256color ;; *) echo "vt100" ;; esac fi } # sorta hacky, but I cannot find a better way to do this :/ fix_terminfo_db () { if [ -d "$1" ] && [ `command -v infocmp 2>/dev/null` = "$1/bin/infocmp" ] ; then TERMINFO="$1/share/terminfo" export TERMINFO fi } 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 if [ -n "${COLORTERM}" -o -n "${XTERM_VERSION}" -o -n "${TERM_PROGRAM}" ]; then if [ "${COLORTERM}" = "gnome-terminal" ] ; then TERM="xterm-256color" fi elif [ -n "${SSH_TTY}" ] ; then answerback_cmd="answerback.`uname -s`" if command -v ${answerback_cmd} >/dev/null 2>&1 ; then ANSWERBACK=`${answerback_cmd} 2>/dev/null` export ANSWERBACK fi fi 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*|xterm-termite) alias screen="screen -T `fix_term xterm-256color`" ;; linux) # Tango palette for framebuffers printf "\033]P02e3436" #black printf "\033]P8555753" #darkgray printf "\033]P1cc0000" #darkred printf "\033]P9ef2929" #red printf "\033]P24e9a06" #darkgreen printf "\033]PA8ae234" #green printf "\033]P3c4a000" #brown printf "\033]PBfce94f" #yellow printf "\033]P43465a4" #darkblue printf "\033]PC729fcf" #blue printf "\033]P575507b" #darkmagenta printf "\033]PDad7fa8" #magenta printf "\033]P606989a" #darkcyan printf "\033]PE34e2e2" #cyan printf "\033]P7ffffff" #lightgray printf "\033]PFeeeeec" #white ;; esac fi