Skip to content

Instantly share code, notes, and snippets.

@ben-vargas
Created August 9, 2025 17:41
Show Gist options
  • Select an option

  • Save ben-vargas/cb0424cf7599daebce9befecdee0fc61 to your computer and use it in GitHub Desktop.

Select an option

Save ben-vargas/cb0424cf7599daebce9befecdee0fc61 to your computer and use it in GitHub Desktop.
Here's your complete statusline setup that you can replicate on another machine:
Status Line Configuration Details
Your setup uses an enhanced custom script (~/.claude/statusline-enhanced.sh) that displays:
- Time (12-hour with AM/PM)
- Current directory with color-coded Git status (blue=clean, orange=dirty)
- Model name (shortened)
- Token usage (~character count/4)
- Global 5-hour session timer with progress percentage
To Replicate on Another Machine:
1. Create settings file ~/.claude/settings.json:
{
"statusLine": {
"type": "command",
"command": "bash ~/.claude/statusline-enhanced.sh"
}
}
2. Copy your 131-line script to ~/.claude/statusline-enhanced.sh and make it executable (chmod +x)
3. Ensure dependencies: jq, git, and standard bash utilities
Key Features:
- Global session tracking (not per-Claude session) - tracks 5-hour work periods
- Smart Git integration - works from any subdirectory
- Color scheme: Primary blue (#0095ff), Git dirty orange (#ff5f15)
- Auto-cleanup of legacy session files
- Token estimation with K/M formatting
The script stores session data in ~/.claude/global_work_session and automatically resets after 5 hours. All Git status checks use git -C to work from the actual repository
location.
#!/bin/bash
# Enhanced Claude Code Status Line
# Shows: Time | Directory | Git Status | Model | Token Usage | Session Timer
# Read JSON input
input=$(cat)
# Extract basic info
current_dir=$(echo "$input" | jq -r '.workspace.current_dir')
model_display=$(echo "$input" | jq -r '.model.display_name')
transcript_path=$(echo "$input" | jq -r '.transcript_path')
session_id=$(echo "$input" | jq -r '.session_id')
# Global 5-hour session timer tracking
global_session_file="$HOME/.claude/global_work_session"
session_timer=""
if [[ -n "$session_id" && "$session_id" != "null" ]]; then
current_timestamp=$(date +%s)
session_duration=18000 # 5 hours in seconds
# Check if we have an active global session
if [[ -f "$global_session_file" ]]; then
session_start=$(cat "$global_session_file" 2>/dev/null)
# Validate the timestamp
if [[ "$session_start" =~ ^[0-9]+$ ]]; then
elapsed=$((current_timestamp - session_start))
# Check if the 5-hour session has expired
if [[ $elapsed -ge $session_duration ]]; then
# Session expired - start a new 5-hour period
echo "$current_timestamp" > "$global_session_file"
session_start=$current_timestamp
elapsed=0
fi
else
# Invalid timestamp - start new session
echo "$current_timestamp" > "$global_session_file"
session_start=$current_timestamp
elapsed=0
fi
else
# No existing session - start new 5-hour period
echo "$current_timestamp" > "$global_session_file"
session_start=$current_timestamp
elapsed=0
fi
# Calculate elapsed time within the current 5-hour period
hours=$((elapsed / 3600))
minutes=$(((elapsed % 3600) / 60))
# Format session timer (e.g., "2h 15m" or "45m")
if [[ $hours -gt 0 ]]; then
session_timer=$(printf "%dh %dm" $hours $minutes)
else
session_timer=$(printf "%dm" $minutes)
fi
# Add session progress indicator (percentage of 5 hours)
progress_percent=$((elapsed * 100 / session_duration))
if [[ $progress_percent -gt 100 ]]; then
progress_percent=100
fi
session_timer="$session_timer (${progress_percent}%)"
# Clean up legacy per-session files if they exist
find "$HOME/.claude" -name "session_*" -type f -delete 2>/dev/null || true
fi
# Get current time in 12-hour format with AM/PM
current_time=$(date '+%I:%M:%S %p')
# Get directory name
dir_name=$(basename "$current_dir")
# Git information with unified color scheme
git_info=""
if git -C "$current_dir" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
branch=$(git -C "$current_dir" branch --show-current 2>/dev/null)
[[ -z "$branch" ]] && branch=$(git -C "$current_dir" rev-parse --short HEAD 2>/dev/null || echo "unknown")
git_status=$(git -C "$current_dir" status --porcelain 2>/dev/null)
if [[ -n "$git_status" ]]; then
# Bright orange-red for modified (#ff5f15)
git_info=$(printf " \033[38;2;255;95;21m(%s*)\033[0m" "$branch")
else
# Bright blue for clean (#0095ff)
git_info=$(printf " \033[38;2;0;149;255m(%s)\033[0m" "$branch")
fi
fi
# Extract model short name (e.g., "Sonnet 4", "Opus", etc.)
model_short=$(echo "$model_display" | sed 's/Claude //' | sed 's/3.5 //' | awk '{print $1, $2}' | sed 's/ $//')
# Estimate token usage from transcript
token_estimate="?"
if [[ -f "$transcript_path" ]] && [[ -r "$transcript_path" ]]; then
# Rough token estimation: ~4 characters per token
# Count total characters in the transcript file
char_count=$(wc -c < "$transcript_path" 2>/dev/null || echo "0")
token_estimate=$((char_count / 4))
# Format with K/M suffixes for readability
if [[ $token_estimate -gt 1000000 ]]; then
token_estimate="$((token_estimate / 1000000))M"
elif [[ $token_estimate -gt 1000 ]]; then
token_estimate="$((token_estimate / 1000))K"
fi
fi
# Build the status line with bright blue color scheme (#0095ff)
# Using consistent :: separators throughout for clean, professional appearance
if [[ -n "$session_timer" ]]; then
printf "\033[38;2;0;149;255m::\033[0m \033[38;2;0;149;255m%s\033[0m \033[38;2;0;149;255m::\033[0m \033[38;2;0;149;255m%s\033[0m%s \033[38;2;0;149;255m::\033[0m \033[38;2;0;149;255m%s\033[0m \033[38;2;0;149;255m::\033[0m \033[38;2;0;149;255m~%s\033[0m \033[38;2;0;149;255m::\033[0m \033[38;2;0;149;255m%s\033[0m \033[38;2;0;149;255m::\033[0m" \
"$current_time" \
"$dir_name" \
"$git_info" \
"$model_short" \
"$token_estimate" \
"$session_timer"
else
# Fallback without session timer if session_id is not available
printf "\033[38;2;0;149;255m::\033[0m \033[38;2;0;149;255m%s\033[0m \033[38;2;0;149;255m::\033[0m \033[38;2;0;149;255m%s\033[0m%s \033[38;2;0;149;255m::\033[0m \033[38;2;0;149;255m%s\033[0m \033[38;2;0;149;255m::\033[0m \033[38;2;0;149;255m~%s\033[0m \033[38;2;0;149;255m::\033[0m" \
"$current_time" \
"$dir_name" \
"$git_info" \
"$model_short" \
"$token_estimate"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment