I've been mucking with my .bashrc file in Gentoo so I might have the username in PS1 change color according to system load, but it's not quite working. When I can get it to stop throwing errors, the color is red when load is 0, and most of the time, bash throws errors (when load is 0, andyway). Here's my bashrc (the modified parts):
Code:
It's telling me '[: ==: unary operator expected' and '[: 00: unary operator expected', still with system load at 0. Any help?
And just for kicks, anyone else customized their prompt?
Code:
function promptmodify
{
local USRCOLOR=""
local FLOAD=$(echo $(uptime | awk '{print $10}'))
local LOAD=$(echo $FLOAD | awk -F . -- '{print $2}')
if [ $(echo $LOAD | awk -F 0 -- '{print $1}') == "0" ]; then
LOAD="$(echo $LOAD | awk -F 0 -- '{print $1}')"
fi
if [ $LOAD >= 100 ]; then
USRCOLOR="\[\033[1;31m\]" #bright red
elif [[ $LOAD<80 && $LOAD<100 ]]; then
USRCOLOR="\[\033[0;33m\]" #dull red
elif [[ $LOAD>50 && $LOAD<81 ]]; then
USRCOLOR="\[\033[0;33m\]" #dull yellow
elif [[ $LOAD>20 && $LOAD<51 ]]; then
USRCOLOR="\[\033[0;32m\]" #dull green
elif [ $LOAD<21 ]; then
USRCOLOR="\[\033[1;34m\]" #bright blue
fi
export PS1="${USRCOLOR}\u${GREEN}@\w\$${GREY} "
}
promptmodify
It's telling me '[: ==: unary operator expected' and '[: 00: unary operator expected', still with system load at 0. Any help?
And just for kicks, anyone else customized their prompt?