Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Last active June 23, 2021 23:54
Show Gist options
  • Save ttscoff/0f0c1a294294906321e30de4431a9a0d to your computer and use it in GitHub Desktop.
Save ttscoff/0f0c1a294294906321e30de4431a9a0d to your computer and use it in GitHub Desktop.
Oneliner to show CPU usage as percent of total cores

Using this as a BetterTouchTool script widget:

  1. launch path: /bin/bash
  2. parameters: -c
  3. script: paste cpupercent.sh contents
printf '%0.0f%% | %0.0f%% | %0.0f%%' $(echo "scale=4;($(uptime | awk '{ print $10 }') / $(sysctl -n hw.ncpu)) * 100" | bc) $(echo "scale=4;($(uptime | awk '{ print $11 }') / $(sysctl -n hw.ncpu)) * 100" | bc) $(echo "scale=4;($(uptime | awk '{ print $12 }') / $(sysctl -n hw.ncpu)) * 100" | bc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment