Skip to content

Instantly share code, notes, and snippets.

@reeslo
Created March 5, 2026 19:59
Show Gist options
  • Select an option

  • Save reeslo/4fcc02fb5d7014638a980bf9002509ec to your computer and use it in GitHub Desktop.

Select an option

Save reeslo/4fcc02fb5d7014638a980bf9002509ec to your computer and use it in GitHub Desktop.
#!/bin/sh
rtk gain -f json 2>/dev/null | awk -F'[:,}]' '
/"total_input"/ { input=$2+0 }
/"total_saved"/ { saved=$2+0 }
/"avg_savings_pct"/ { pct=$2+0 }
END {
if (input > 0) {
fmt_input = (input >= 1000) ? sprintf("%.1fK", input/1000) : input
fmt_saved = (saved >= 1000) ? sprintf("%.1fK", saved/1000) : saved
printf "RTK: %s/%s saved (%.0f%%)\n", fmt_saved, fmt_input, pct
} else {
print "RTK: no data"
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment