#!/bin/bash input=$(cat) cwd=$(echo "$input" | jq -r '.workspace.current_dir') user=$(whoami) host=$(hostname -s) # Colors RESET='\033[0m' CYAN='\033[36m' GREEN='\033[32m' YELLOW='\033[33m' RED='\033[31m' BLUE='\033[34m' MAGENTA='\033[35m' DIM='\033[2m' output="${CYAN}${user}@${host}${RESET}${DIM}:${RESET}${BLUE}${cwd}${RESET}" # Get git info if in a git repo if git -C "$cwd" rev-parse --git-dir > /dev/null 2>&1; then git_branch=$(git -C "$cwd" branch --show-current 2>/dev/null) # Get git status counts staged=$(git -C "$cwd" diff --cached --numstat 2>/dev/null | wc -l) modified=$(git -C "$cwd" diff --numstat 2>/dev/null | wc -l) untracked=$(git -C "$cwd" ls-files --others --exclude-standard 2>/dev/null | wc -l) # Build status string with icons status="" [ "$staged" -gt 0 ] && status+="${GREEN}✚${staged}${RESET} " [ "$modified" -gt 0 ] && status+="${YELLOW}✎${modified}${RESET} " [ "$untracked" -gt 0 ] && status+="${RED}?${untracked}${RESET} " status=$(echo -e "$status" | sed 's/ $//') # trim trailing space git_info="${MAGENTA} ${git_branch}${RESET}" [ -n "$status" ] && git_info+=" ${status}" output+=" ${DIM}│${RESET}${git_info}" fi # Calculate context window 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)) # Color based on usage level if [ "$pct" -lt 50 ]; then pct_color="${GREEN}" elif [ "$pct" -lt 75 ]; then pct_color="${YELLOW}" else pct_color="${RED}" fi output+=" ${DIM}│${RESET} ${pct_color}󰄛 ${pct}%${RESET}" fi printf "%b" "$output"