Add FreeBSD uptime, fix formatting again

This commit is contained in:
Connor Sheridan 2021-03-25 17:57:42 -04:00
commit 6f577c0610
No known key found for this signature in database
GPG key ID: F63E070C165D2362
2 changed files with 69 additions and 68 deletions

View file

@ -30,6 +30,9 @@ __uptime() {
if [ -r /proc/uptime ]; then
read u idle < /proc/uptime
u=${u%.*}
elif [ $(uname) = "FreeBSD" ]; then
u=$( sysctl -n kern.boottime | sed -En 's:.*sec = ([[:digit:]]+),.*:\1:p' )
u=$(($(date +%s) - $u))
elif [ -x /usr/sbin/sysctl ]; then
# MacOS support
u=$(/usr/sbin/sysctl -n kern.boottime | cut -f4 -d' ' | cut -d',' -f1)
@ -52,5 +55,3 @@ __uptime() {
[ -n "$str" ] || return
color w b; printf "%s" "${str}"; color --
}
# vi: syntax=sh ts=4 noexpandtab