Comment 1 for bug 103929

Revision history for this message
Micah Cowan (micahcowan) wrote :

No; that'll kill it for the xterm-color users, then. Could do xterm|xterm-color)...

Either way, it's a poor way to check for color support; better to check the terminal database. I propose this version:

--- skel.bashrc.orig 2007-04-06 16:37:35.000000000 -0700
+++ skel.bashrc 2007-04-06 16:56:16.000000000 -0700
@@ -20,18 +20,19 @@
     debian_chroot=$(cat /etc/debian_chroot)
 fi

-# set a fancy prompt (non-color, unless we know we "want" color)
-case "$TERM" in
-xterm-color)
+# set a fancy prompt (color, when supported)
+
+if tput setaf 1 >&/dev/null
+then
+ # We have color support; assume it's compliant with Ecma-48
+ # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+ # a case would tend to support setf rather than setaf.)
     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
- ;;
-*)
+else
+ # Color apparently unsupported (or don't have tput(!)). Issue
+ # prompt, sans color sequences
     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
- ;;
-esac
-
-# Comment in the above and uncomment this below for a color prompt
-#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+fi

 # If this is an xterm set the title to user@host:dir
 case "$TERM" in