-# 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
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 chroot= $(cat /etc/debian_chroot)
+++ skel.bashrc 2007-04-06 16:56:16.000000000 -0700
@@ -20,18 +20,19 @@
debian_
fi
-# set a fancy prompt (non-color, unless we know we "want" color) '${debian_ chroot: +($debian_ chroot) }\[\033[ 01;32m\ ]\u@\h\ [\033[00m\ ]:\[\033[ 01;34m\ ]\w\[\033[ 00m\]\$ ' '${debian_ chroot: +($debian_ chroot) }\u@\h: \w\$ ' ${debian_ chroot: +($debian_ chroot) }\[\033[ 01;32m\ ]\u@\h\ [\033[00m\ ]:\[\033[ 01;34m\ ]\w\[\033[ 00m\]\$ '
-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=
- ;;
-*)
+else
+ # Color apparently unsupported (or don't have tput(!)). Issue
+ # prompt, sans color sequences
PS1=
- ;;
-esac
-
-# Comment in the above and uncomment this below for a color prompt
-#PS1='
+fi
# If this is an xterm set the title to user@host:dir
case "$TERM" in