From f5757053144627072421376776ac959f70af72d0 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 22 Oct 2012 22:17:01 +0100 Subject: [PATCH] Try to handle unrecognised terminals. Fall back to various degrees of xterm if the inherited TERM variable isn't usable. This should be thought of as a last resort. In general it is a bad idea to try to overrule TERM. --- .profile.d/TERM.bashrc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.profile.d/TERM.bashrc b/.profile.d/TERM.bashrc index 5bb800c..7294ab8 100644 --- a/.profile.d/TERM.bashrc +++ b/.profile.d/TERM.bashrc @@ -1 +1,15 @@ export TERMINFO=${PROFILE_HOME:-~}/.terminfo + +# Cygwin MinTTY. +[ "$OS" = "Cygwin" -a "$TERM" = "xterm" ] && export TERM=putty-256color + +# Check the terminal is valid. +while [ -z "$(tput longname 2>/dev/null)" ]; do + case $TERM in + xterm-256color) export TERM=xterm-88color;; + xterm-88color) export TERM=xterm-color;; + xterm-color) export TERM=xterm;; + xterm) break;; + *) export TERM=xterm-256color;; + esac +done -- 2.7.4