|
Lines 59-85
Link Here
|
| 59 |
# Set colorful PS1 only on colorful terminals. |
59 |
# Set colorful PS1 only on colorful terminals. |
| 60 |
# dircolors --print-database uses its own built-in database |
60 |
# dircolors --print-database uses its own built-in database |
| 61 |
# instead of using /etc/DIR_COLORS. Try to use the external file |
61 |
# instead of using /etc/DIR_COLORS. Try to use the external file |
| 62 |
# first to take advantage of user additions. Use internal bash |
62 |
# first to take advantage of user additions. |
| 63 |
# globbing instead of external grep binary. |
63 |
if type -P dircolors >/dev/null ; then |
| 64 |
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM |
64 |
LS_COLORS="" |
| 65 |
match_lhs="" |
65 |
if [[ -f ~/.dir_colors ]] ; then |
| 66 |
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)" |
66 |
eval "$(dircolors -b ~/.dir_colors)" |
| 67 |
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)" |
67 |
elif [[ -f /etc/DIR_COLORS ]] ; then |
| 68 |
[[ -z ${match_lhs} ]] \ |
68 |
eval "$(dircolors -b /etc/DIR_COLORS)" |
| 69 |
&& type -P dircolors >/dev/null \ |
69 |
else |
| 70 |
&& match_lhs=$(dircolors --print-database) |
70 |
eval "$(dircolors)" |
| 71 |
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true |
|
|
| 72 |
|
| 73 |
if ${use_color} ; then |
| 74 |
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489 |
| 75 |
if type -P dircolors >/dev/null ; then |
| 76 |
if [[ -f ~/.dir_colors ]] ; then |
| 77 |
eval $(dircolors -b ~/.dir_colors) |
| 78 |
elif [[ -f /etc/DIR_COLORS ]] ; then |
| 79 |
eval $(dircolors -b /etc/DIR_COLORS) |
| 80 |
fi |
| 81 |
fi |
71 |
fi |
|
|
72 |
[[ -n "$LS_COLORS" ]] && use_color=true |
| 73 |
fi |
| 74 |
|
| 82 |
|
75 |
|
|
|
76 |
if ${use_color} ; then |
| 83 |
if [[ ${EUID} == 0 ]] ; then |
77 |
if [[ ${EUID} == 0 ]] ; then |
| 84 |
PS1+='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] ' |
78 |
PS1+='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] ' |
| 85 |
else |
79 |
else |
|
Lines 105-108
Link Here
|
| 105 |
done |
99 |
done |
| 106 |
|
100 |
|
| 107 |
# Try to keep environment pollution down, EPA loves us. |
101 |
# Try to keep environment pollution down, EPA loves us. |
| 108 |
unset use_color safe_term match_lhs sh |
102 |
unset use_color sh |