Skip to content

Instantly share code, notes, and snippets.

@mba811
Forked from viplup/cpu_usage.sh
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save mba811/ea46f0e41e1b635a5fb6 to your computer and use it in GitHub Desktop.

Select an option

Save mba811/ea46f0e41e1b635a5fb6 to your computer and use it in GitHub Desktop.
Today Scripts:个性化 Yosemite 通知栏-CPU
ps xro %cpu=,comm= | while read cpu comm; ((i++<5)); do
int=$cpu
int="${int%%.*}"
if (($int >= 50)); then color=$'\e[31m';
elif (($int >= 25)); then color=$'\e[33m';
else color=$'\e[32m';
fi;
echo "$color$cpu% $(basename "$comm")"$'\e[0m'"";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment