show battery in prompt and have it update after every command 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 == &quot;3&quot; ]; then
            if [ $proc_num != &quot;100&quot; ]; 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=&quot;\u@&quot;
_PS1host=&quot;$txtred\h&quot;
_PS1time=&quot;$txtwht | \t | &quot;
_PS1battery=&quot;`battery_status`&quot;
_PS1end=&quot;$txtrst\n\w › &quot;

export PS1=&quot;$_PS1user$_PS1host$_PS1time$_PS1battery$_PS1end&quot;

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.)
You have to escape it, if you want it to rerun every time it gets called. It can easiest be done with the dollar-sign.

_PS1battery="\$(battery_status)"