Skip to content

Instantly share code, notes, and snippets.

@EvanLovely
Forked from sarcasticsimba/cpu_usage.sh
Last active August 29, 2015 14:11
Show Gist options
  • Save EvanLovely/7edc4815efc4536e087c to your computer and use it in GitHub Desktop.
Save EvanLovely/7edc4815efc4536e087c to your computer and use it in GitHub Desktop.
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