Suggestion to improve /etc/bashrc --------------------------------- Currently, /etc/bashrc has this: case $TERM in xterm*) PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD\ 007"' ;; *) ;; esac The behavior is fine; however, I administer multiple systems and would like to have an easier way to modifiy the $PROMPT_COMMAND I would like those lines to be replaced with something like this: case $TERM in xterm*) PROMPT_COMMAND=/usr/bin/prompt-xterm ;; *) PROMPT_COMMAND=/usr/bin/prompt-default ;; esac in /usr/bin/prompt-xterm, I have this: echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD}\007" /usr/bin/prompt-default in /usr/bin/prompt-default is where I have my own stuff. Additional Info/History ----------------------- I did this because I wanted a more intelligent mail-notification system. So many times I get the message "New mail has arrived." when it hasn't. Sometimes I don't get notified. Sometimes I get notified on two different ssh sessions. I use qmail. What I did was this: in my /etc/qmail/control/aliasempty file I put this: ./Maildir/ |echo `date '+%s'` >$HOME/.newmail (When new mail arrives, qmail puts the date the mail arrived in $HOME/.newmail. This has the format of seconds since 00:00:00 Jan 1, 1970. If another message arrives, the date of the latest message overwrites any previous values in $HOME/.newmail.) In /usr/bin/prompt-default, I have this: if [ -f $HOME/.newmail ]; then ARRIVED=`cat $HOME/.newmail` rm $HOME/.newmail AGE=$[`date '+%s'`-$ARRIVED] if [ $AGE -lt 0 ] ; then NOTIFY="New mail has arrived." elif [ $AGE -eq 0 ] ; then NOTIFY="New mail just arrived." else if [ $AGE -lt 60 ] ; then QTY=$AGE UNIT="second" elif [ $AGE -lt 3600 ]; then QTY=$[($AGE+30)/60] UNIT="minute" elif [ $AGE -lt 86400 ]; then QTY=$[($AGE+1800)/3600] UNIT="hour" else QTY=$[($AGE+43200)/86400] UNIT="day" fi if [ $QTY -ne 1 ]; then UNIT="$UNIT"s fi NOTIFY="New mail arrived $QTY $UNIT ago." fi echo echo " * $NOTIFY" echo fi (Every time I press return in an interactive bash shell, the system does a quick check to see if $HOME/.newmail has arrived. If so, it calculates how long ago it arrived and formats it into a nice, user- friendly format like this: * New mail arrived 7 minutes ago I receive this message only once, on only one terminal, and it is always a true statement.) I have my email client renamed (mutt --> mutt-binary) and run from a script (mutt). In the mutt script, after the binary has exited, it deletes $HOME/.newmail so that I don't hear about email received while I was reading mail. I'm not proposing that everyone adopt my email notification system (it is very nice, though). I just want a generic way for everyone to be able to implement their own $PROMPT_COMMAND enhancements.
The problem with this is that it increases the overhead for every command by starting another shell etc. It makes slow machines a real pain.
I've added something similar as an option in 2.05-1: If /etc/sysconfig/bash-prompt-xterm exists, it is used instead of setting the default prompt in an xterm; in other terminals, /etc/sysconfig/bash-prompt-default is used. If they don't exist (and they aren't included in the package), everything remains the way it was, saving overhead.