Created
February 18, 2026 16:24
-
-
Save rikonor/cc3e07e5d81e1e2a838b05cb48abcd34 to your computer and use it in GitHub Desktop.
~/.claude/statusline-command.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Read JSON input | |
| input=$(cat) | |
| # Extract values | |
| dir=$(echo "$input" | jq -r '.workspace.current_dir') | |
| model=$(echo "$input" | jq -r '.model.display_name') | |
| style=$(echo "$input" | jq -r '.output_style.name') | |
| transcript_path=$(echo "$input" | jq -r '.transcript_path') | |
| # Get agent identity from git config | |
| agent="" | |
| if [ -n "$GIT_AUTHOR_EMAIL" ]; then | |
| agent=$(echo "$GIT_AUTHOR_EMAIL" | sed 's/@.*//') | |
| fi | |
| # Get directory name (like %c in zsh) | |
| dirname=$(basename "$dir") | |
| # Check if we're in a git repo and get branch | |
| if git -C "$dir" rev-parse --git-dir > /dev/null 2>&1; then | |
| branch=$(git -C "$dir" rev-parse --abbrev-ref HEAD 2>/dev/null) | |
| # Check if repo is dirty (skip optional locks) | |
| if ! git -C "$dir" diff --quiet 2>/dev/null || ! git -C "$dir" diff --cached --quiet 2>/dev/null; then | |
| git_status="git:($branch) ✗" | |
| else | |
| git_status="git:($branch)" | |
| fi | |
| git_info=" $git_status" | |
| else | |
| git_info="" | |
| fi | |
| # Calculate context usage percentage | |
| usage=$(echo "$input" | jq '.context_window.current_usage') | |
| if [ "$usage" != "null" ]; then | |
| current=$(echo "$usage" | jq '.input_tokens + .cache_creation_input_tokens + .cache_read_input_tokens') | |
| size=$(echo "$input" | jq '.context_window.context_window_size') | |
| pct=$((current * 100 / size)) | |
| context_info=" · ${pct}%" | |
| else | |
| context_info="" | |
| fi | |
| # Calculate session duration | |
| if [ -f "$transcript_path" ]; then | |
| # Get transcript creation time (session start) | |
| if [[ "$OSTYPE" == "darwin"* ]]; then | |
| # macOS | |
| start_time=$(stat -f %B "$transcript_path" 2>/dev/null) | |
| else | |
| # Linux | |
| start_time=$(stat -c %Y "$transcript_path" 2>/dev/null) | |
| fi | |
| if [ -n "$start_time" ]; then | |
| now=$(date +%s) | |
| duration=$((now - start_time)) | |
| # Format duration | |
| hours=$((duration / 3600)) | |
| minutes=$(((duration % 3600) / 60)) | |
| if [ $hours -gt 0 ]; then | |
| duration_info=" · ${hours}h${minutes}m" | |
| else | |
| duration_info=" · ${minutes}m" | |
| fi | |
| else | |
| duration_info="" | |
| fi | |
| else | |
| duration_info="" | |
| fi | |
| # Build status line with colors (using dimmed terminal colors) | |
| # Cyan for directory, blue for git, magenta for agent, dimmed for model | |
| printf "\033[36m%s\033[0m%s" "$dirname" "$git_info" | |
| # Add agent before model (reads as "agent via model") | |
| if [ -n "$agent" ]; then | |
| printf " \033[35m%s\033[0m ·" "$agent" | |
| fi | |
| printf " \033[2m%s\033[0m" "$model" | |
| # Add output style if not default | |
| if [ "$style" != "default" ]; then | |
| printf "\033[2m · %s\033[0m" "$style" | |
| fi | |
| # Add context usage and duration | |
| printf "\033[2m%s%s\033[0m" "$context_info" "$duration_info" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment