Files
ai-setup/home-configs/claude/statusline-command.sh

21 lines
765 B
Bash

#!/bin/bash
input=$(cat)
cwd=$(echo "$input" | jq -r '.cwd')
model=$(echo "$input" | jq -r '.model.display_name // empty')
five_pct=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
week_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
branch=$(git -C "$cwd" --no-optional-locks symbolic-ref --short HEAD 2>/dev/null)
short_cwd="${cwd/#$HOME/\~}"
printf "\033[01;34m%s\033[00m" "$short_cwd"
[ -n "$branch" ] && printf " \033[01;33m[%s]\033[00m" "$branch"
[ -n "$model" ] && printf " \033[00;36m%s\033[00m" "$model"
if [ -n "$five_pct" ]; then
printf " \033[00;35m5h:$(printf '%.0f' "$five_pct")%%\033[00m"
elif [ -n "$week_pct" ]; then
printf " \033[00;35m7d:$(printf '%.0f' "$week_pct")%%\033[00m"
fi