Created
June 30, 2025 09:47
-
-
Save shinshin86/11841dbf55197fcb7b2691e8756aecf1 to your computer and use it in GitHub Desktop.
Display the cost of the most recent 1-hour usage period in large ASCII art
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
#!/usr/bin/env bash | |
# show-cc-1-hour-cost.sh : Display the cost of the most recent 1-hour usage period in large ASCII art | |
set -euo pipefail | |
# --- Settings ------------------------------------------------------------ | |
# Edit here if you want to change the font, colors, or other oh-my-logo options | |
LOGO_STYLE="fire --filled" | |
# ------------------------------------------------------------------------- | |
# Get today’s date in YYYYMMDD (depends on system locale) | |
TODAY=$(date +%Y%m%d) | |
# Call the blocks API to fetch 1-hour usage blocks and | |
# extract costUSD from the newest block, rounded to two decimals | |
COST=$( | |
npx ccusage@latest blocks --since "$TODAY" --session-length 1 --json \ | |
| jq -r '(.blocks[-1].costUSD * 100 | round) / 100 | tostring' | |
) | |
# Render the logo | |
npx oh-my-logo "\$${COST}" $LOGO_STYLE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment