Skip to content

Commit

Permalink
Proper uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
vesrah committed Apr 18, 2015
1 parent 74295df commit aa7046f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion OSXey
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,20 @@ esac
version="OS X $versionNumber $versionString"

# ==UPTIME==
uptime=$(uptime | sed 's/.*up \([^,]*\), .*/\1/')
if [ "$(uptime | sed -e "s/:/ /2" | sed -e "s/,/ /2" | awk '{print $6}')" = "users" ]
then
# 1 hour < uptime < 1 day
uptime="$(uptime | sed -e "s/:/ /2" | sed -e "s/,/ /2" | awk '{$4=substr($4,1,length($4)-1); print $3 " hours and " $4 " minutes"}')"
else
if [ "$(uptime | sed -e "s/:/ /2" | sed -e "s/,/ /2" | awk '{print $5}')" = "min," ]
then
# uptime < 1 hour
uptime="$(uptime | sed -e "s/:/ /2" | sed -e "s/:/ /2" | sed -e "s/,/ /2" | awk '{print $4 " minutes"}')"
else
# uptime > 1 day
uptime="$(uptime | sed -e "s/:/ /2" | sed -e "s/,/ /2" | awk '{print $3 " days, " $5 " hours and " $6 " minutes"}')"
fi
fi

# ==SHELL==
shell="$SHELL"
Expand Down

0 comments on commit aa7046f

Please sign in to comment.