Created
April 2, 2015 00:58
-
-
Save kitten/a2ca1a7718d9fe94aa7d to your computer and use it in GitHub Desktop.
Little bash function that uses Spark to display the CPU usage on a dual core Mac.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cpu() { | |
usage=$(ps aux | awk {'sum+=$3;print int(sum/4+.5)'} | tail -n 1) | |
graph=$(spark 0 ${usage} 100 | awk '{print substr($0,4,3)}') | |
echo "[$usage%] $graph" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
int(sum/4+.5)
can be modified for quad core or single code machines (or any). Just replace the4
with your number of cores. Remember Hyper Threading.