|
|
|
|
|
by michaelhoffman
4973 days ago
|
|
I use this, which allows a similar effect but is enabled for PIPESTATUS, and also does some good things for eterm and screen. PIPESTATUS_REGEX="^ +$"
# check to see if any of the pipe statuses don't start with 0
# ${_CMD_PIPESTATUS[@]#0} results in null if they all do
_PIPESTATUS="
_CMD_PIPESTATUS=(\${PIPESTATUS[@]})
if [[ \"\${_CMD_PIPESTATUS[*]#0}\" && ! \"\${_CMD_PIPESTATUS[*]#0}\" =~ \$PIPESTATUS_REGEX ]]
then
_RES_STR=\" [\${_CMD_PIPESTATUS[*]}]\";
else
_RES_STR=''
fi"
export PROMPT_COMMAND="$_PIPESTATUS; $PROMPT_COMMAND"
if [[ $TERM = screen || $_TERM = screen ]]; then
_RESET_PROMPT="\[\033k\033\\\\\]"
else
_RESET_PROMPT=""
fi
if [ $TERM = "eterm-color" ]; then
# XXX: this is going to break things when you start
# use $INSIDE_EMACS to test whether we should use \u?
_ETERM_PROMPT="\[\033AnSiTu \u\012\033AnSiTc \w\012\033AnSiTh \H\012\]"
else
_ETERM_PROMPT=""
fi
export PS1="\n$_ETERM_PROMPT\[\033[32m\]\u@\h \[\033[33m\]\w\[\033[35m\]\$_RES_STR\[\033[0m\]\n${_RESET_PROMPT}\\$ "
unset _RESET_PROMPT
|
|