mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 14:03:18 -07:00
Fixes the uptime status notification on OS X.
This commit is contained in:
parent
85c1971722
commit
757ba0fbdc
1 changed files with 11 additions and 4 deletions
|
@ -30,18 +30,25 @@ __uptime() {
|
|||
if [ -r /proc/uptime ]; then
|
||||
read u idle < /proc/uptime
|
||||
u=${u%.*}
|
||||
elif [ -x /usr/sbin/sysctl ]; then
|
||||
u=$(/usr/sbin/sysctl -n kern.boottime | cut -f4 -d' ' | cut -d',' -f1)
|
||||
u=$(($(date +%s) - $u))
|
||||
fi
|
||||
|
||||
if [ "$u" ]; then
|
||||
if [ "$u" -gt 86400 ]; then
|
||||
str="$(($u / 86400))d$((($u % 86400) / 3600))h"
|
||||
str="$(($u / 86400))d$((($u % 86400) / 3600))h"
|
||||
elif [ "$u" -gt 3600 ]; then
|
||||
str="$(($u / 3600))h$((($u % 3600) / 60))m"
|
||||
str="$(($u / 3600))h$((($u % 3600) / 60))m"
|
||||
elif [ "$u" -gt 60 ]; then
|
||||
str="$(($u / 60))m"
|
||||
str="$(($u / 60))m"
|
||||
else
|
||||
str="${u}s"
|
||||
str="${u}s"
|
||||
fi
|
||||
else
|
||||
str=$(uptime | sed -e "s/.* up *//" -e "s/ *days, */d/" -e "s/:/h/" -e "s/,.*/m/")
|
||||
fi
|
||||
|
||||
[ -n "$str" ] || return
|
||||
color w b; printf "%s" "${str}"; color --
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue