From d2b5bd92b5e0c90fc2c58e0c66509b92cda52526 Mon Sep 17 00:00:00 2001 From: Bill Ballou Date: Wed, 7 Jan 2026 08:13:08 -0500 Subject: [PATCH] Add feature-rich statusline with colors and git status - Display user@host:path with colored output - Show git branch with icon and file status indicators - Include context window usage percentage with color coding - Use Nerd Font icons for visual appeal --- settings.json | 2 +- statusline-command.sh | 60 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100755 statusline-command.sh diff --git a/settings.json b/settings.json index 0298fec..7e70300 100644 --- a/settings.json +++ b/settings.json @@ -37,7 +37,7 @@ }, "statusLine": { "type": "command", - "command": "printf '\\033[01;32m%s@%s\\033[00m:\\033[01;34m%s\\033[00m' \"$(whoami)\" \"$(hostname -s)\" \"$(pwd)\"" + "command": "/home/bill/.claude/statusline-command.sh" }, "enabledPlugins": { "superpowers@superpowers-marketplace": true, diff --git a/statusline-command.sh b/statusline-command.sh new file mode 100755 index 0000000..361d696 --- /dev/null +++ b/statusline-command.sh @@ -0,0 +1,60 @@ +#!/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"