diff options
author | Aron Griffis <agriffis@gentoo.org> | 2004-08-19 01:31:20 +0000 |
---|---|---|
committer | Aron Griffis <agriffis@gentoo.org> | 2004-08-19 01:31:20 +0000 |
commit | 8a38e8f73bb6fcc28439f2eb6d1b947928ee136f (patch) | |
tree | c1ff921c391388c5bc251a4e60ad48c2ca996fcc /app-shells/bash/files/bashrc | |
parent | PPC stable profile update (Manifest recommit) (diff) | |
download | gentoo-2-8a38e8f73bb6fcc28439f2eb6d1b947928ee136f.tar.gz gentoo-2-8a38e8f73bb6fcc28439f2eb6d1b947928ee136f.tar.bz2 gentoo-2-8a38e8f73bb6fcc28439f2eb6d1b947928ee136f.zip |
grep /etc/DIR_COLORS for terminals instead of running dircolors #59937
Diffstat (limited to 'app-shells/bash/files/bashrc')
-rw-r--r-- | app-shells/bash/files/bashrc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/app-shells/bash/files/bashrc b/app-shells/bash/files/bashrc index 0490253fc209..2d69fc92cc28 100644 --- a/app-shells/bash/files/bashrc +++ b/app-shells/bash/files/bashrc @@ -1,5 +1,5 @@ # /etc/bash.bashrc: -# $Header: /var/cvsroot/gentoo-x86/app-shells/bash/files/bashrc,v 1.3 2004/08/14 03:10:00 agriffis Exp $ +# $Header: /var/cvsroot/gentoo-x86/app-shells/bash/files/bashrc,v 1.4 2004/08/19 01:31:20 agriffis Exp $ # # This file is sourced by all *interactive* bash shells on startup, # including some apparently interactive shells such as scp and rcp @@ -14,8 +14,20 @@ if [[ $- != *i* ]]; then return fi -# Set colorful PS1 only on colorful terminals -if dircolors --print-database | grep -Fqx "TERM $TERM"; then +# Set colorful PS1 only on colorful terminals. +# dircolors --print-database uses its own built-in database +# instead of using /etc/DIR_COLORS. Try to use the external file +# first to take advantage of user additions. +use_color=false +safe_term=${TERM//[^[:alnum:]]/.} # sanitize TERM + +if [[ -f /etc/DIR_COLORS ]]; then + grep -q "^TERM ${safe_term}" /etc/DIR_COLORS && use_color=true +elif dircolors --print-database | grep -q "^TERM ${safe_term}"; then + use_color=true +fi + +if ${use_color}; then if [[ $EUID == 0 ]]; then PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]' else |