i just fresh-installed Lion, and i am in the process of seeing up my system. i am using this function (found somewhere online...) to show it in the prompt :
battery_status()
{
maxcap=`ioreg -l | grep Capacity | awk '/MaxCapacity/{print $5}'`
curcap=`ioreg -l | grep Capacity | awk '/CurrentCapacity/{print $5}'`
curcap=`echo $curcap*1000|bc`
proc=`echo $curcap / $maxcap |bc`;
len=`echo ${#proc}`;
proc_num=${proc:0:3}
proc_dec=${proc:3:4}
proc_num_len=`echo ${#proc_num}`;
if [ $proc_num_len == "3" ]; then
if [ $proc_num != "100" ]; then
proc_num=${proc:0:2}
proc_dec=${proc:2:3}
fi
fi
echo $proc_num.$proc_dec%
}
And i generate my prompt like this :
_PS1user="\u@"
_PS1host="$txtred\h"
_PS1time="$txtwht | \t | "
_PS1battery="`battery_status`"
_PS1end="$txtrst\n\w › "
export PS1="$_PS1user$_PS1host$_PS1time$_PS1battery$_PS1end"
unset _PS1user _PS1host _PS1time _PS1battery _PS1end
However, since Lion, the battery Part is not updated every time the prompt appears again. For example, if i do a ls and wait for the battery to drained and then do another command in the same window, without having re source my .bashrc, the battery stays the same.
does anyone know how to have it updated without having to resource my .bashrcfile resourced every time ?
(By the way, this is how my prompt looks like.)