Created
February 6, 2026 14:04
-
-
Save jancimajek/051dca12088d30bc2c8262000270500c 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 from stdin | |
| input=$(cat) | |
| echo "$input" > ~/.claude/debug_input.json | |
| # Extract current directory and model name from JSON | |
| cwd=$(echo "$input" | jq -r '.workspace.current_dir // .cwd') | |
| model_name=$(echo "$input" | jq -r '.model.display_name') | |
| # Start building output with model name in orange | |
| output=$(printf '\033[38;5;208m%s\033[0m' "$model_name") | |
| # Add context window usage in purple | |
| 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)) | |
| output+=" $(printf '\033[38;5;129m%d%%\033[0m' "$pct")" | |
| fi | |
| # Replace home directory with π‘ emoji and truncate all but current dir to first charachers | |
| dir_display=$(echo "$cwd" | sed "s|^$HOME|π‘|" | awk -F'/' '{for (i = 1; i < NF; i++){ printf substr($(i), 1, 1)"/" }}{printf "\033[38;5;45m%s\033[0m", $(NF)}') | |
| output+=" ${dir_display}" | |
| # Add git info if in a git repo | |
| if git -C "$cwd" rev-parse --git-dir > /dev/null 2>&1; then | |
| # Get branch name | |
| branch=$(git -C "$cwd" --no-optional-locks branch --show-current 2>/dev/null || git -C "$cwd" --no-optional-locks rev-parse --short HEAD 2>/dev/null) | |
| # Get git status | |
| git_status=$(git -C "$cwd" --no-optional-locks status --porcelain 2>/dev/null) | |
| # status_colour="" | |
| if [ -n "$git_status" ]; then | |
| # status_symbols="" | |
| if echo "$git_status" | grep -q "^M\|^A"; then | |
| # Staged | |
| output+=" πΏ $(printf '\033[38;5;214m%s\033[0m' "$branch")" | |
| elif echo "$git_status" | grep -q "^ M"; then | |
| # Modified | |
| output+=" πΏ $(printf '\033[94m%s\033[0m' "$branch")" | |
| elif echo "$git_status" | grep -q "^??"; then | |
| # Untracked | |
| output+=" πΏ $(printf '\033[38;5;46m%s\033[0m' "$branch")" | |
| fi | |
| # # Check for modified files | |
| # if echo "$git_status" | grep -q "^ M"; then | |
| # status_symbols+="π΅" | |
| # output+=" πΏ $(printf '\033[94m%s\033[0m' "$branch")" | |
| # fi | |
| # # Check for staged files | |
| # if echo "$git_status" | grep -q "^M\|^A"; then | |
| # status_symbols+="π " | |
| # status_colour='\033[33;1m' | |
| # fi | |
| # # Check for untracked files | |
| # if echo "$git_status" | grep -q "^??"; then | |
| # status_symbols+="π’" | |
| # status_colour='\033[32;1m' | |
| # fi | |
| # if [ -n "$status_symbols" ]; then | |
| # output+=" ${status_symbols}" | |
| # fi | |
| else | |
| output+=" πΏ $branch" | |
| fi | |
| fi | |
| # Add current time | |
| current_time=$(date +%H:%M:%S) | |
| output+=" π ${current_time}" | |
| printf "%s" "$output" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment