Skip to content

Commit a81b74e

Browse files
authored
Merge pull request #3 from RafalLukawiecki/master
Fix cpu.sh on macOS with multiple disk drives
2 parents 2a85770 + 44d326b commit a81b74e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/cpu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ get_cpu_color(){
3939
get_cpu_usage() {
4040
if is_osx; then
4141
if command_exists "iostat"; then
42-
iostat -c 2 -w "$refresh_interval" | tail -n 1 | awk '{ print 100-$6 }'
42+
iostat -c 2 -w "$refresh_interval" | tail -n 1 | awk '{ print 100-$(NF-3) }'
4343
else
4444
top -l 2 -s "$refresh_interval" -n 0 | sed -nr '/CPU usage/s/.*,[[:space:]]*([0-9]+[.,][0-9]*)%[[:space:]]*idle.*/\1/p' | tail -n 1 | awk '{ print 100-$0 }'
4545
fi

0 commit comments

Comments
 (0)