Skip to content

Instantly share code, notes, and snippets.

@AvasDream
Created January 2, 2026 13:03
Show Gist options
  • Select an option

  • Save AvasDream/73617886e42e4b8074f1456c3f0b7d22 to your computer and use it in GitHub Desktop.

Select an option

Save AvasDream/73617886e42e4b8074f1456c3f0b7d22 to your computer and use it in GitHub Desktop.
Claude Code Setup

Statsline

{
  "permissions": {
    "allow": [
      "WebSearch",
      "WebFetch(domain:authjs.dev)",
      "WebFetch(domain:www.npmjs.com)",
      "Bash(npm run build:*)",
      "WebFetch(domain:errors.authjs.dev)",
      "Bash(ls:*)",
      "Bash(find:*)",
      "Bash(cat:*)",
      "Bash(tree:*)",
      "Bash(npm install:*)",
      "Bash(npx tsc:*)",
      "WebFetch(domain:ai-sdk.dev)",
      "WebFetch(domain:github.com)",
      "Bash(xargs cat:*)",
      "Skill(ast-grep)",
      "Bash(grep:*)",
      "WebFetch(domain:bundlephobia.com)",
      "Bash(ast-grep run:*)",
      "mcp__ide__getDiagnostics",
      "Skill(ast-grep:ast-grep)",
      "Bash(npm run build:check:*)",
      "Bash(npx prisma migrate:*)",
      "Bash(npx prisma db push)",
      "Bash(npx prisma db push:*)",
      "WebFetch(domain:developers.google.com)",
      "Bash(docker info:*)",
      "Bash(devcontainer build:*)",
      "Bash(docker stop:*)",
      "Bash(devcontainer up:*)",
      "Bash(docker exec:*)",
      "Bash(docker rm:*)",
      "Bash(docker rmi:*)",
      "Bash(docker builder prune:*)",
      "Bash(docker ps:*)",
      "Bash(xargs:*)",
      "Bash(curl:*)",
      "Bash(bun run:*)",
      "Skill(nextjs)",
      "Bash(npm test)"
    ],
    "deny": [],
    "ask": []
  },
  "hooks": {},
  "statusLine": {
    "type": "command",
    "command": "bash .claude/statusline-command.sh"
  }
}
#!/bin/bash

# Color codes (ANSI)
GREEN='\033[0;32m'
LIGHT_GREEN='\033[0;92m'
YELLOW='\033[0;33m'
ORANGE='\033[0;38;5;208m'
RED='\033[0;31m'
RESET='\033[0m'

# Read JSON input from stdin
input=$(cat)

# Extract context window info from JSON
CONTEXT_SIZE=$(echo "$input" | jq -r '.context_window.context_window_size')
USAGE=$(echo "$input" | jq '.context_window.current_usage')

# Calculate current tokens and percentage
if [ "$USAGE" != "null" ]; then
    # Sum up all token usage: input + cache creation + cache read
    USED_TOKENS=$(echo "$USAGE" | jq '.input_tokens + .cache_creation_input_tokens + .cache_read_input_tokens')
    TOTAL_TOKENS="$CONTEXT_SIZE"

    if [ "$TOTAL_TOKENS" -gt 0 ]; then
        PERCENTAGE=$((USED_TOKENS * 100 / TOTAL_TOKENS))
    else
        PERCENTAGE=0
    fi
else
    USED_TOKENS=0
    TOTAL_TOKENS="$CONTEXT_SIZE"
    PERCENTAGE=0
fi

# Determine color based on percentage (20% increments)
if [ "$PERCENTAGE" -lt 20 ]; then
    COLOR="$GREEN"
elif [ "$PERCENTAGE" -lt 40 ]; then
    COLOR="$LIGHT_GREEN"
elif [ "$PERCENTAGE" -lt 60 ]; then
    COLOR="$YELLOW"
elif [ "$PERCENTAGE" -lt 80 ]; then
    COLOR="$ORANGE"
else
    COLOR="$RED"
fi

# Format context display with color
CONTEXT_DISPLAY="${COLOR}${USED_TOKENS}/${TOTAL_TOKENS} (${PERCENTAGE}%)${RESET}"

# Get cost from JSON
COST_USD=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
# Format cost to 4 decimal places
COST_DISPLAY=$(printf '$%.4f' "$COST_USD")

# Get model name from JSON
MODEL_NAME=$(echo "$input" | jq -r '.model.display_name // "Claude"')

# Get git branch (if in git repo)
GIT_BRANCH=""
if git rev-parse --git-dir > /dev/null 2>&1; then
    GIT_BRANCH=$(git branch --show-current 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
    if [ -n "$GIT_BRANCH" ]; then
        GIT_BRANCH=" | git:${GIT_BRANCH}"
    fi
fi

# Get Python virtual environment
PYTHON_ENV=""
if [ -n "$VIRTUAL_ENV" ]; then
    PYTHON_ENV=" | venv:$(basename "$VIRTUAL_ENV")"
elif [ -n "$CONDA_DEFAULT_ENV" ]; then
    PYTHON_ENV=" | conda:${CONDA_DEFAULT_ENV}"
fi

# Output the status line
echo -e "${MODEL_NAME} | ${CONTEXT_DISPLAY} | ${COST_DISPLAY}${GIT_BRANCH}${PYTHON_ENV}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment