Advertisement
Guest User

proper xterm-256color support in Gnome terminal

a guest
Nov 21st, 2012
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.18 KB | None | 0 0
  1. if [ "$TERM" = "xterm" ] ; then
  2.     if [ -z "$COLORTERM" ] ; then
  3.         if [ -z "$XTERM_VERSION" ] ; then
  4.             echo "Warning: Terminal wrongly calling itself 'xterm'."
  5.         else
  6.             case "$XTERM_VERSION" in
  7.             "XTerm(256)") TERM="xterm-256color" ;;
  8.             "XTerm(88)") TERM="xterm-88color" ;;
  9.             "XTerm") ;;
  10.             *)
  11.                 echo "Warning: Unrecognized XTERM_VERSION: $XTERM_VERSION"
  12.                 ;;
  13.             esac
  14.         fi
  15.     else
  16.         case "$COLORTERM" in
  17.             gnome-terminal)
  18.                 # Those crafty Gnome folks require you to check COLORTERM,
  19.                 # but don't allow you to just *favor* the setting over TERM.
  20.                 # Instead you need to compare it and perform some guesses
  21.                 # based upon the value. This is, perhaps, too simplistic.
  22.                 TERM="xterm-256color"
  23.                 # TERM="gnome-256color"
  24.                 ;;
  25.             *)
  26.                 echo "Warning: Unrecognized COLORTERM: $COLORTERM"
  27.                 ;;
  28.         esac
  29.     fi
  30. fi
  31. SCREEN_COLORS="`tput colors`"
  32. if [ -z "$SCREEN_COLORS" ] ; then
  33.     case "$TERM" in
  34.         screen-*color-bce)
  35.             echo "Unknown terminal $TERM. Falling back to 'screen-bce'."
  36.             export TERM=screen-bce
  37.             ;;
  38.         *-88color)
  39.             echo "Unknown terminal $TERM. Falling back to 'xterm-88color'."
  40.             export TERM=xterm-88color
  41.             ;;
  42.         *-256color)
  43.             echo "Unknown terminal $TERM. Falling back to 'xterm-256color'."
  44.             export TERM=xterm-256color
  45.             ;;
  46.     esac
  47.     SCREEN_COLORS=`tput colors`
  48. fi
  49. if [ -z "$SCREEN_COLORS" ] ; then
  50.     case "$TERM" in
  51.         gnome*|xterm*|konsole*|aterm|[Ee]term)
  52.             echo "Unknown terminal $TERM. Falling back to 'xterm'."
  53.             export TERM=xterm
  54.             ;;
  55.         rxvt*)
  56.             echo "Unknown terminal $TERM. Falling back to 'rxvt'."
  57.             export TERM=rxvt
  58.             ;;
  59.         screen*)
  60.             echo "Unknown terminal $TERM. Falling back to 'screen'."
  61.             export TERM=screen
  62.             ;;
  63.     esac
  64.     SCREEN_COLORS=`tput colors`
  65. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement