diff options
author | Mike Frysinger <vapier@gentoo.org> | 2016-02-02 15:23:37 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2016-02-03 13:51:41 -0500 |
commit | 43785a6ff3210efdb6807a42fb02ed74b440019c (patch) | |
tree | 23ee4984365aa7ad5aeb8164155b9226c300f47c /app-shells | |
parent | app-shells/bash: bashrc: simplify/unify TERM checking slightly (diff) | |
download | gentoo-43785a6ff3210efdb6807a42fb02ed74b440019c.tar.gz gentoo-43785a6ff3210efdb6807a42fb02ed74b440019c.tar.bz2 gentoo-43785a6ff3210efdb6807a42fb02ed74b440019c.zip |
app-shells/bash: bashrc: enable fallback TERM color checking for everyone
We provide rudimentary TERM checking for BSD which doesn't have dircolors,
but this logic works just as well for all systems such as embedded. Make
this code run whenever dircolors does not exist.
Diffstat (limited to 'app-shells')
-rw-r--r-- | app-shells/bash/files/bashrc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app-shells/bash/files/bashrc b/app-shells/bash/files/bashrc index f3618fc647c3..87a55629f695 100644 --- a/app-shells/bash/files/bashrc +++ b/app-shells/bash/files/bashrc @@ -49,18 +49,12 @@ case ${TERM} in ;; esac -use_color=false -#BSD#@# BSD doesn't typically come with dircolors so we need -#BSD#@# to hardcode some terminals in here. -#BSD#@case ${TERM} in -#BSD#@ [aEkx]term*|rxvt*|gnome*|konsole*|screen|cons25) use_color=true;; -#BSD#@esac - # 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 internal bash # globbing instead of external grep binary. +use_color=false safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM match_lhs="" [[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)" @@ -79,7 +73,15 @@ if ${use_color} ; then eval $(dircolors -b /etc/DIR_COLORS) fi fi +else + # Some systems (e.g. BSD & embedded) don't typically come with + # dircolors so we need to hardcode some terminals in here. + case ${TERM} in + [aEkx]term*|rxvt*|gnome*|konsole*|screen|cons25) use_color=true;; + esac +fi +if ${use_color} ; then if [[ ${EUID} == 0 ]] ; then PS1+='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] ' else |