Skip to content

Instantly share code, notes, and snippets.

@tfausak
Last active May 8, 2026 15:03
Show Gist options
  • Select an option

  • Save tfausak/18345d9565296b81134781e4aa126b27 to your computer and use it in GitHub Desktop.

Select an option

Save tfausak/18345d9565296b81134781e4aa126b27 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
# https://code.claude.com/docs/en/statusline
json=$( cat )
directory=$( basename "$( printf '%s' "$json" | jq --raw-output .workspace.current_dir )" )
branch=$( git --no-optional-locks symbolic-ref --short HEAD 2>/dev/null || printf null )
model=$( printf '%s' "$json" | jq --raw-output .model.id )
case "$model" in
'claude-opus-4-7' ) model=opus-4.7 ;;
'claude-opus-4-7[1m]' ) model=opus-4.7 ;;
esac
effort=$( printf '%s' "$json" | jq --raw-output .effort.level )
used=$( printf '%.0f' "$( printf '%s' "$json" | jq '.context_window.used_percentage // 0' )" )
cost=$( printf '%.2f' "$( printf '%s' "$json" | jq '.cost.total_cost_usd // 0' )" )
exec printf '%s' \
"$( tput setaf 5 )" "$directory " "$( tput sgr0 )" \
"$( tput setaf 4 )" "$branch " "$( tput sgr0 )" \
"$( tput setaf 6 )" "$model " "$( tput sgr0 )" \
"$( tput setaf 7 )" "$effort " "$( tput sgr0 )" \
"$( tput setaf 3 )" "$used% " "$( tput sgr0 )" \
"$( tput setaf 2 )" "\$$cost" "$( tput sgr0 )"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment