Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 2.37 KB

File metadata and controls

64 lines (47 loc) · 2.37 KB

Claude Code 스크립트

context-bar.sh

Claude Code용 2줄 상태 표시줄 스크립트로, 모델, 디렉토리, git 브랜치, 커밋되지 않은 파일 수, origin과의 동기화 상태, 컨텍스트 사용량, 마지막 메시지를 보여줍니다.

출력 예시:

Opus 4.5 | 📁claude-code-tips | 🔀main (scripts/context-bar.sh uncommitted, synced 12m ago) | ██░░░░░░░░ 18% of 200k tokens
💬 This is good. I don't think we need to change the documentation as long as we don't say that the default color is orange el...

설치 방법

  1. 스크립트를 Claude 스크립트 디렉토리에 복사합니다:

    mkdir -p ~/.claude/scripts
    cp context-bar.sh ~/.claude/scripts/
    chmod +x ~/.claude/scripts/context-bar.sh
  2. ~/.claude/settings.json을 업데이트합니다:

    {
      "statusLine": {
        "type": "command",
        "command": "~/.claude/scripts/context-bar.sh"
      }
    }

끝입니다!

색상 테마

이 스크립트는 모델 이름과 진행 막대에 선택적 색상 테마를 지원합니다. 스크립트 상단의 COLOR 변수를 수정하세요:

# 색상 테마: gray, orange, blue, teal, green, lavender, rose, gold, slate, cyan
COLOR="orange"

모든 옵션을 미리 보려면 bash scripts/color-preview.sh를 실행하세요:

색상 미리보기 옵션

필수 조건

  • jq (JSON 파싱용)
  • bash
  • git (선택 사항, 브랜치 표시용)
  • Claude Code 2.0.65+ (동작 확인됨; 이전 버전에는 필요한 JSON 필드가 없을 수 있음 - 이전 버전은 과거 커밋을 확인하세요)

동작 원리

Claude Code는 상태 표시줄 명령에 JSON으로 세션 메타데이터를 stdin을 통해 전달합니다. 포함 항목:

  • model.display_name - 모델 이름
  • cwd - 현재 작업 디렉토리
  • context_window.total_input_tokens - 사용된 총 입력 토큰
  • context_window.total_output_tokens - 사용된 총 출력 토큰
  • context_window.context_window_size - 최대 컨텍스트 윈도우 크기
  • transcript_path - 세션 트랜스크립트 JSONL 파일 경로

이 스크립트는 이 JSON 필드들을 사용하여 컨텍스트 사용량(입력 + 출력 토큰)을 계산하고, 컨텍스트 윈도우 대비 백분율을 표시합니다. 정확한 토큰 분석은 /context를 사용하세요.