Created
February 25, 2026 23:20
-
-
Save facastagnini/85a2d5217674346f0e0edfcdbf826c40 to your computer and use it in GitHub Desktop.
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/zsh | |
| input=$(cat) | |
| IFS=$'\t' read -r MODEL DIR PCT <<< "$(echo "$input" | jq -r '[.model.display_name, .workspace.current_dir, (.context_window.used_percentage // 0 | tostring | split(".")[0])] | join("\t")')" | |
| CYAN='\033[36m' | |
| FG_LIGHT_GRAY='\033[38;5;7m' | |
| FG_DARK_GRAY='\033[38;5;232m' | |
| YELLOW='\033[33m' | |
| RED='\033[31m' | |
| GREEN='\033[32m' | |
| RESET='\033[0m' | |
| FG_ORANGE='\033[38;5;172m' | |
| FG_BLACK='\033[30m' | |
| FG_BLUE='\033[38;5;32m' | |
| FG_GREEN='\033[38;5;76m' | |
| BG_GREEN='\033[48;5;76m' | |
| BG_ORANGE='\033[48;5;172m' | |
| BG_BLUE='\033[48;5;32m' | |
| BG_LIGHT_GRAY='\033[48;5;7m' | |
| BG_DARK_GRAY='\033[48;5;232m' | |
| # Special nerd font symbols | |
| ARROW_RIGHT='\ue0b0' | |
| FOLDER='\uf07c' | |
| GIT='\uf126' | |
| # Pick context glyph and color based on usage | |
| if [ "$PCT" -ge 90 ]; then CTX_GLYPH="●"; CTX_COLOR="$RED" | |
| elif [ "$PCT" -ge 70 ]; then CTX_GLYPH="◕"; CTX_COLOR="$RED" | |
| elif [ "$PCT" -ge 45 ]; then CTX_GLYPH="◑"; CTX_COLOR="$FG_BLACK" | |
| elif [ "$PCT" -ge 20 ]; then CTX_GLYPH="◔"; CTX_COLOR="$FG_BLACK" | |
| else CTX_GLYPH="○"; CTX_COLOR="$FG_BLACK"; fi | |
| GIT_TTL=3 | |
| BRANCH="${RESET}${FG_BLUE}${ARROW_RIGHT}${RESET}" | |
| if git rev-parse --git-dir > /dev/null 2>&1; then | |
| REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) | |
| REPO_HASH=$(echo -n "$REPO_ROOT" | md5 -qs 2>/dev/null || echo -n "$REPO_ROOT" | md5sum | cut -c1-32) | |
| CACHE_FILE="${TMPDIR:-/tmp}/claude-sl-git-${REPO_HASH}" | |
| NOW=$(date +%s) | |
| USE_CACHE=false | |
| if [ -f "$CACHE_FILE" ]; then | |
| IFS='|' read -r C_TIME C_BRANCH C_CHANGED C_UNTRACKED < "$CACHE_FILE" | |
| if [ $((NOW - C_TIME)) -lt $GIT_TTL ]; then | |
| USE_CACHE=true | |
| BRANCH_NAME="$C_BRANCH" | |
| CHANGED="$C_CHANGED" | |
| UNTRACKED="$C_UNTRACKED" | |
| fi | |
| fi | |
| if [ "$USE_CACHE" = false ]; then | |
| BRANCH_NAME=$(git branch --show-current 2>/dev/null) | |
| if [ -n "$BRANCH_NAME" ]; then | |
| GIT_STATUS=$(git status --porcelain 2>/dev/null) | |
| if [ -z "$GIT_STATUS" ]; then | |
| CHANGED=0; UNTRACKED=0 | |
| else | |
| CHANGED=$(echo "$GIT_STATUS" | grep -cv '^??') | |
| UNTRACKED=$(echo "$GIT_STATUS" | grep -c '^??') | |
| fi | |
| echo "${NOW}|${BRANCH_NAME}|${CHANGED}|${UNTRACKED}" > "$CACHE_FILE" | |
| fi | |
| fi | |
| if [ -n "$BRANCH_NAME" ]; then | |
| if [ "$CHANGED" -eq 0 ] && [ "$UNTRACKED" -eq 0 ]; then | |
| BG="$BG_GREEN" | |
| FG="$FG_GREEN" | |
| else | |
| BG="$BG_ORANGE" | |
| FG="$FG_ORANGE" | |
| fi | |
| INDICATORS="" | |
| if [ "$CHANGED" -gt 0 ]; then INDICATORS="!${CHANGED}"; fi | |
| if [ "$UNTRACKED" -gt 0 ]; then INDICATORS="${INDICATORS}\033[34m?${UNTRACKED}"; fi | |
| BRANCH="${FG_BLUE}${BG}${ARROW_RIGHT}${FG_BLACK} ${GIT} ${BRANCH_NAME} ${INDICATORS} ${RESET}${FG}${ARROW_RIGHT}${RESET}" | |
| fi | |
| fi | |
| echo -e "${RESET}${FG_BLACK}${BG_LIGHT_GRAY} $MODEL ${CTX_COLOR}${CTX_GLYPH}${FG_LIGHT_GRAY}${BG_BLUE}${ARROW_RIGHT}${FG_LIGHT_GRAY} ${FOLDER} ${DIR##*/} $BRANCH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment