Try to handle unrecognised terminals.
authorIain Patterson <me@iain.cx>
Mon, 22 Oct 2012 21:17:01 +0000 (22:17 +0100)
committerIain Patterson <me@iain.cx>
Mon, 22 Oct 2012 21:54:28 +0000 (22:54 +0100)
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

index 5bb800c..7294ab8 100644 (file)
@@ -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