fi
+use_color=false
if [[ $- == *i* ]]; then
# for readline-complete.el
if [[ $LC_INSIDE_EMACS ]]; then
bind '"\C-i": self-insert'
else
+
+ if [[ $TERM != dumb ]] && test -t 1; then
+ use_color=true
+ fi
+
if [[ $KONSOLE_PROFILE_NAME ]]; then
TERM=xterm-256color
fi
# * misc stuff
-# temporary variables to test colorization
-# some copied from gentoo /etc/bash/bashrc,
-use_color=false
-# 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.
-safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
-match_lhs=""
-[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
-[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
-[[ -z ${match_lhs} ]] \
- && type -P dircolors >/dev/null \
- && match_lhs=$(dircolors --print-database)
-# test if our $TERM is in the TERM values in dircolor
-[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true
-
-
-if ${use_color} && [[ $- == *i* ]]; then
+if $use_color; then
term_bold="$(tput bold)"
term_red="$(tput setaf 1)"
0) ps_color="$term_purple"
ps_char='\$'
;;
- 1) ps_color="$term_green"
- ps_char="$return \\$"
- ;;
- *) ps_color="$term_yellow"
+ *) ps_color="$term_green"
ps_char="$return \\$"
;;
esac
# but then we get an email and log of lots of failed sudo commands.
# We could turn those off, but seems better not to.
if [[ $EUID != 0 ]] && [[ $DID_SUDO ]]; then
- ps_char="SUDO $ps_char"
+ psudo="\[$term_bold$term_red\]s\[$term_nocolor\] "
fi
if [[ ! $HISTFILE ]]; then
ps_char="NOHIST $ps_char"
fi
- PS1="${PS1%"${PS1#*[wW]}"} \[$ps_color\]$ps_char\[$term_nocolor\] "
+ PS1="${PS1%"${PS1#*[wW]}"} $psudo\[$ps_color\]$ps_char\[$term_nocolor\] "
# set titlebar. instead, using more advanced
# titelbar below