Skip to content

Instantly share code, notes, and snippets.

@birgitta410
Created February 19, 2026 16:45
Show Gist options
  • Select an option

  • Save birgitta410/1ea3928059a9dc53f81a32cdab02a773 to your computer and use it in GitHub Desktop.

Select an option

Save birgitta410/1ea3928059a9dc53f81a32cdab02a773 to your computer and use it in GitHub Desktop.
Claude Code status line script that shows day to day things with similar energy usage as the current session
#!/bin/bash
# Status line script for Claude Code, originally copied from https://code.claude.com/docs/en/statusline
# Then had Claude Code research energy usage and display every day activities based on cost that would supposedly use similar levels of energy
#
# Energy per token (from napkin math scaling ChatGPT-4o data):
# Input: ~0.39 Wh per 1k tokens (390 Wh/million)
# Output: ~1.95 Wh per 1k tokens (1950 Wh/million)
# Sources: https://www.simonpcouch.com/blog/2026-01-20-cc-impact/
# https://arxiv.org/html/2505.09598v1
input=$(cat)
MODEL=$(echo "$input" | jq -r '.model.display_name')
DIR=$(echo "$input" | jq -r '.workspace.current_dir')
COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
DURATION_MS=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
INPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_input_tokens // 0')
OUTPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')
CYAN='\033[36m'; GREEN='\033[32m'; YELLOW='\033[33m'; RED='\033[31m'; DIM='\033[2m'; RESET='\033[0m'
pick_random() { local arr=("$@"); echo "${arr[$((RANDOM % ${#arr[@]}))]}" ; }
# Format token count: 0, 1.2k, 45k, 1.2M, etc.
format_tokens() {
local t=$1
if [ "$t" -lt 1000 ]; then echo "${t}"
elif [ "$t" -lt 1000000 ]; then echo "$(echo "scale=1; $t / 1000" | bc)k"
else echo "$(echo "scale=1; $t / 1000000" | bc)M"
fi
}
# Estimate energy in Wh from token counts
# Input: ~0.39 Wh/1k tokens, Output: ~1.95 Wh/1k tokens
# [simonpcouch.com/blog/2026-01-20-cc-impact/]
calc_energy_wh() {
echo "scale=1; ($1 * 0.39 + $2 * 1.95) / 1000" | bc 2>/dev/null
}
energy_equivalent() {
local wh_raw=$(calc_energy_wh "$1" "$2")
# Convert to integer centiwatt-hours for comparison (Wh ร— 100 to avoid floats)
local cwh=$(echo "$wh_raw * 100 / 1" | bc 2>/dev/null)
[ -z "$cwh" ] && cwh=0
# Google search: ~0.3 Wh each (0.0003 kWh)
# [store.chipkin.com; fullfact.org/environment/google-search/; rwdigital.ca]
if [ "$cwh" -lt 400 ]; then # < 4 Wh
pick_random \
"โšก a sip of energy" \
"๐Ÿ’ก an LED on for 20 min" \
"๐Ÿ” ~10 Google searches"
# LED: 10W ร— 20min = 3.3 Wh [energyusecalculator.com/electricity_ledlightbulb.htm]
# Google: 10 ร— 0.3 Wh = 3 Wh
elif [ "$cwh" -lt 1100 ]; then # ~4-11 Wh
pick_random \
"๐Ÿ’ก an LED bulb for 1 hour" \
"๐Ÿ”‹ half a phone charge" \
"๐Ÿ“บ 10 min of TV" \
"๐Ÿ” ~25 Google searches"
# LED: 10W ร— 1h = 10 Wh [energyusecalculator.com/electricity_ledlightbulb.htm]
# Phone: typical charge ~10-20 Wh, half โ‰ˆ 5-10 Wh [energysage.com; energyusecalculator.com/electricity_cellphone.htm]
# TV: ~60W ร— 10min = 10 Wh [energybot.com/energy-usage/tv.html; jackery.com]
# Google: 25 ร— 0.3 Wh = 7.5 Wh
elif [ "$cwh" -lt 2600 ]; then # ~11-26 Wh
pick_random \
"๐Ÿ”‹ a full phone charge" \
"๐Ÿ’ก an LED bulb for 2 hours" \
"๐Ÿ“บ 20 min of TV" \
"๐Ÿ” ~60 Google searches"
# Phone: ~10-20 Wh per charge [energysage.com; energyusecalculator.com/electricity_cellphone.htm]
# LED: 10W ร— 2h = 20 Wh [energyusecalculator.com/electricity_ledlightbulb.htm]
# TV: ~60W ร— 20min = 20 Wh [energybot.com/energy-usage/tv.html]
# Google: 60 ร— 0.3 Wh = 18 Wh
elif [ "$cwh" -lt 5600 ]; then # ~26-56 Wh
pick_random \
"๐Ÿ“บ 1 hour of TV" \
"๐Ÿ’ป a laptop for 1 hour" \
"๐Ÿ”‹ 3 phone charges" \
"๐Ÿ” ~140 Google searches"
# TV: ~50-60W ร— 1h = 50-60 Wh [energybot.com/energy-usage/tv.html; jackery.com]
# Laptop: 30-60W ร— 1h = 30-60 Wh [energysage.com; energyusecalculator.com/electricity_laptop.htm]
# Phone: 3 ร— ~15 Wh = 45 Wh [energyusecalculator.com/electricity_cellphone.htm]
# Google: 140 ร— 0.3 Wh = 42 Wh
elif [ "$cwh" -lt 11200 ]; then # ~56-112 Wh
pick_random \
"๐Ÿž making toast" \
"๐Ÿ‘” ironing a shirt" \
"๐Ÿ’‡ a hairdryer for 3 min" \
"๐Ÿ“บ 2 hours of TV" \
"๐Ÿ” ~280 Google searches"
# Toast: 1200W ร— 3min = 60 Wh [energyusecalculator.com/electricity_toaster.htm; energybot.com/energy-usage/toaster.html]
# Iron: ~1100W ร— 5min = 92 Wh [energyusecalculator.com/electricity_iron.htm; energybot.com/energy-usage/iron.html]
# Hairdryer: 1500W ร— 3min = 75 Wh [energysage.com; energyusecalculator.com/electricity_hairdryer.htm]
# TV: ~50W ร— 2h = 100 Wh [energybot.com/energy-usage/tv.html]
# Google: 280 ร— 0.3 Wh = 84 Wh
elif [ "$cwh" -lt 22400 ]; then # ~112-224 Wh
pick_random \
"๐Ÿš— 1 km in an EV" \
"โ˜• boiling a kettle" \
"๐Ÿงน 15 min of vacuuming" \
"๐ŸŽฎ 1 hour of console gaming" \
"๐Ÿ” ~560 Google searches"
# EV: avg ~150 Wh/km [ev-database.org/cheatsheet/energy-consumption-electric-car]
# Kettle: ~100-150 Wh per boil [bluettipower.com; atidymind.co.uk; ecoflow.com]
# Vacuum: ~700W ร— 15min = 175 Wh [energyusecalculator.com/electricity_vacuum.htm; energybot.com]
# Console: PS5/Xbox ~200W ร— 1h = 200 Wh [energyusecalculator.com/electricity_gameconsole.htm; ecocostsavings.com]
# Google: 560 ร— 0.3 Wh = 168 Wh
elif [ "$cwh" -lt 37400 ]; then # ~225-374 Wh
pick_random \
"๐Ÿš— 2 km in an EV" \
"โ˜• boiling 3 kettles" \
"๐Ÿ‘• a cold washing machine cycle" \
"๐Ÿณ frying an egg on electric" \
"๐Ÿ” ~1,000 Google searches"
# EV: 2 ร— 150 Wh = 300 Wh [ev-database.org/cheatsheet/energy-consumption-electric-car]
# Kettles: 3 ร— ~120 Wh = 360 Wh [bluettipower.com; atidymind.co.uk]
# Cold wash: 300-500 Wh [energysage.com; energyusecalculator.com/electricity_clotheswasher.htm; directenergy.com]
# Frying: ~1500W ร— 10min (heat-up + cook) = 250 Wh [directenergy.com; ecoflow.com; energyusecalculator.com/electricity_stovetop.htm]
# Google: 1000 ร— 0.3 Wh = 300 Wh
elif [ "$cwh" -lt 60000 ]; then # ~375-600 Wh
pick_random \
"๐Ÿš— 3 km in an EV" \
"๐Ÿ’ป a workday on a laptop" \
"๐Ÿ“บ 10 hours of TV" \
"๐Ÿงน 1 hour of vacuuming" \
"๐Ÿ” ~1,600 Google searches"
# EV: 3 ร— 150 Wh = 450 Wh [ev-database.org/cheatsheet/energy-consumption-electric-car]
# Laptop: ~50W ร— 8h = 400 Wh [energysage.com; energyusecalculator.com/electricity_laptop.htm; ecocostsavings.com]
# TV: ~50W ร— 10h = 500 Wh [energybot.com/energy-usage/tv.html]
# Vacuum: ~700W ร— 1h = 700 Wh [energyusecalculator.com/electricity_vacuum.htm] (top of range)
# Google: 1600 ร— 0.3 Wh = 480 Wh
elif [ "$cwh" -lt 90000 ]; then # ~600-900 Wh
pick_random \
"๐Ÿš— 5 km in an EV" \
"๐Ÿ• baking a pizza" \
"๐Ÿณ cooking dinner on a stovetop" \
"๐Ÿ‘• a hot washing machine cycle" \
"๐Ÿ” ~2,500 Google searches"
# EV: 5 ร— 150 Wh = 750 Wh [ev-database.org/cheatsheet/energy-consumption-electric-car]
# Pizza: oven ~2500W ร— 20min = 833 Wh [energyusecalculator.com/electricity_oven.htm; bomakitchen.com]
# Stovetop dinner: ~2000W ร— 30min = 1000 Wh [directenergy.com; energyusecalculator.com/electricity_stovetop.htm] (top of range)
# Hot wash: 1.5-2.0 kWh per cycle at 60ยฐC+ [energysage.com; directenergy.com; energyusecalculator.com/electricity_clotheswasher.htm]
# Google: 2500 ร— 0.3 Wh = 750 Wh
elif [ "$cwh" -lt 150000 ]; then # ~900-1500 Wh
pick_random \
"๐Ÿฝ๏ธ a dishwasher cycle" \
"๐Ÿš— 8 km in an EV" \
"๐ŸงŠ a fridge for a day" \
"๐Ÿ‘• a dryer cycle" \
"๐Ÿ” ~4,000 Google searches"
# Dishwasher: ~1.2 kWh per cycle [energyusecalculator.com/electricity_dishwasher.htm; directenergy.com; searshomeservices.com]
# EV: 8 ร— 150 Wh = 1200 Wh [ev-database.org/cheatsheet/energy-consumption-electric-car]
# Fridge: 1-2 kWh/day, modern avg ~1.2 kWh [energyusecalculator.com/electricity_refrigerator.htm; directenergy.com]
# Dryer: ~2-3 kWh per cycle [energysage.com; ecocostsavings.com/dryer-wattage/; whirlpool.ca]
# Google: 4000 ร— 0.3 Wh = 1200 Wh
elif [ "$cwh" -lt 300000 ]; then # ~1500-3000 Wh
pick_random \
"๐Ÿš— 15 km in an EV" \
"๐Ÿ  an average home for 2 hours" \
"๐Ÿ› a hot bath" \
"๐Ÿฝ๏ธ 2 dishwasher + dryer cycles" \
"๐Ÿ” ~7,500 Google searches"
# EV: 15 ร— 150 Wh = 2250 Wh [ev-database.org/cheatsheet/energy-consumption-electric-car]
# Home: US avg ~1250 Wh/hour ร— 2 = 2500 Wh [eia.gov/tools/faqs/faq.php?id=97; constellation.com]
# Bath: heating 150L by 40ยฐC โ‰ˆ 7 kWh, but with mixing ~5 kWh [withouthotair.com/c7/page_50.shtml]
# Dishwasher+dryer: ~1.2 + 2.5 = 3.7 kWh ร— 2 is over, single combo โ‰ˆ 3.7 kWh
# Google: 7500 ร— 0.3 Wh = 2250 Wh
else # ~3000+ Wh
pick_random \
"๐Ÿš— 20+ km in an EV" \
"๐Ÿ  an average US home for 3 hours" \
"๐ŸงŠ a fridge for 3 days" \
"๐Ÿ› a hot bath + a dryer cycle" \
"๐Ÿ” ~10,000+ Google searches"
# EV: 20 ร— 150 Wh = 3000 Wh [ev-database.org/cheatsheet/energy-consumption-electric-car]
# Home: US avg ~1250 Wh/hour ร— 3 = 3750 Wh [eia.gov/tools/faqs/faq.php?id=97]
# Fridge: ~1.2 kWh/day ร— 3 = 3.6 kWh [energyusecalculator.com/electricity_refrigerator.htm]
# Bath + dryer: ~5 kWh + 2.5 kWh = 7.5 kWh [withouthotair.com; ecocostsavings.com/dryer-wattage/] (top of range)
# Google: 10000 ร— 0.3 Wh = 3000 Wh
fi
}
ENERGY=$(energy_equivalent "$INPUT_TOKENS" "$OUTPUT_TOKENS")
# Format token counts
TOTAL_TOKENS=$((INPUT_TOKENS + OUTPUT_TOKENS))
TOKENS_FMT=$(format_tokens "$TOTAL_TOKENS")
IN_FMT=$(format_tokens "$INPUT_TOKENS")
OUT_FMT=$(format_tokens "$OUTPUT_TOKENS")
# Pick bar color based on context usage
if [ "$PCT" -ge 90 ]; then BAR_COLOR="$RED"
elif [ "$PCT" -ge 70 ]; then BAR_COLOR="$YELLOW"
else BAR_COLOR="$GREEN"; fi
FILLED=$((PCT / 10)); EMPTY=$((10 - FILLED))
BAR=$(printf "%${FILLED}s" | tr ' ' 'โ–ˆ')$(printf "%${EMPTY}s" | tr ' ' 'โ–‘')
MINS=$((DURATION_MS / 60000)); SECS=$(((DURATION_MS % 60000) / 1000))
BRANCH=""
git rev-parse --git-dir > /dev/null 2>&1 && BRANCH=" | ๐ŸŒฟ $(git branch --show-current 2>/dev/null)"
echo -e "${CYAN}[$MODEL]${RESET} ๐Ÿ“ ${DIR##*/}$BRANCH"
COST_FMT=$(printf '$%.2f' "$COST")
echo -e "${BAR_COLOR}${BAR}${RESET} ${PCT}% | ${YELLOW}${COST_FMT}${RESET} | ๐Ÿ“Š ${IN_FMT}in/${OUT_FMT}out ${DIM}โ‰ˆ ${ENERGY}${RESET} | โฑ๏ธ ${MINS}m ${SECS}s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment