Created
March 7, 2026 14:23
-
-
Save Jian-Min-Huang/e63aa4cc6fbddee6286d79bd8f936a26 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 | |
| # Read JSON input from stdin | |
| input=$(cat) | |
| # Extract values using jq | |
| CURRENT_TIME=$(date "+%Y-%m-%d %H:%M:%S") | |
| MODEL_DISPLAY=$(echo "$input" | jq -r '.model.display_name // "unknown"') | |
| CURRENT_DIR=$(echo "$input" | jq -r '.workspace.current_dir // "."') | |
| TOTAL_COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0' | xargs printf "%.2f") | |
| TOTAL_LINE_ADDED=$(echo "$input" | jq -r '.cost.total_lines_added // 0') | |
| TOTAL_LINE_REMOVED=$(echo "$input" | jq -r '.cost.total_lines_removed // 0') | |
| USED_PERCENTAGE=$(echo "$input" | jq -r '.context_window.used_percentage // 0') | |
| ICO_MODEL=$'\ue28c' | |
| ICO_FOLDER=$'\uf413' | |
| ICO_GIT=$'\ue725' | |
| ICO_CONTEXT=$'\uf201' | |
| ICO_CODE=$'\uf121' | |
| ICO_COST='$' | |
| ICO_TIME=$'\ue384' | |
| # Powerline round separator (requires Nerd Font) | |
| SEP=$'\uE0B4' | |
| # Git branch | |
| GIT_BRANCH="" | |
| if git rev-parse --git-dir > /dev/null 2>&1; then | |
| BRANCH=$(git branch --show-current 2>/dev/null) | |
| if [ -n "$BRANCH" ]; then | |
| GIT_BRANCH="$BRANCH" | |
| fi | |
| fi | |
| # ── Color Scheme: Dracula (256-color) ──────────── | |
| # Segment 1: Model — Dracula Purple (#bd93f9) | |
| BG1=141; FG1=232 | |
| # Segment 2: Dir — Dracula Pink (#ff79c6) | |
| BG2=212; FG2=232 | |
| # Segment 3: Git — Dracula Cyan (#8be9fd) | |
| BG3=117; FG3=232 | |
| # Segment 4: Context — Dracula Green (#50fa7b) | |
| BG4=84; FG4=232 | |
| # Segment 5: Lines — Dracula Yellow (#f1fa8c) | |
| BG5=228; FG5=232 | |
| # Segment 6: Cost — Dracula Orange (#ffb86c) | |
| BG6=215; FG6=232 | |
| # Segment 7: Time — Dracula Comment (#6272a4) | |
| BG7=61; FG7=253 | |
| # Accent colors: Dracula Green / Red | |
| C_GREEN=84 | |
| C_RED=203 | |
| # ── Build Output ───────────────────────────────── | |
| OUT="" | |
| # Left round cap | |
| LSEP=$'\uE0B6' | |
| OUT+="\e[38;5;${BG1}m${LSEP}" | |
| # Segment 1: Model | |
| OUT+="\e[38;5;${FG1}m\e[48;5;${BG1}m${ICO_MODEL} ${MODEL_DISPLAY} " | |
| OUT+="\e[38;5;${BG1}m\e[48;5;${BG2}m${SEP}" | |
| # Segment 2: Dir | |
| DIR_DISPLAY="${CURRENT_DIR/#$HOME/~}" | |
| OUT+="\e[38;5;${FG2}m\e[48;5;${BG2}m ${ICO_FOLDER} ${DIR_DISPLAY} " | |
| if [ -n "$GIT_BRANCH" ]; then | |
| OUT+="\e[38;5;${BG2}m\e[48;5;${BG3}m${SEP}" | |
| # Segment 3: Git | |
| OUT+="\e[38;5;${FG3}m\e[48;5;${BG3}m ${ICO_GIT} ${GIT_BRANCH} " | |
| OUT+="\e[38;5;${BG3}m\e[48;5;${BG4}m${SEP}" | |
| else | |
| OUT+="\e[38;5;${BG2}m\e[48;5;${BG4}m${SEP}" | |
| fi | |
| # Segment 4: Context | |
| OUT+="\e[38;5;${FG4}m\e[48;5;${BG4}m ${ICO_CONTEXT} ${USED_PERCENTAGE}% " | |
| OUT+="\e[38;5;${BG4}m\e[48;5;${BG5}m${SEP}" | |
| # Segment 5: Lines | |
| OUT+="\e[38;5;${FG5}m\e[48;5;${BG5}m ${ICO_CODE} +${TOTAL_LINE_ADDED},\e[38;5;${C_RED}m-${TOTAL_LINE_REMOVED}\e[38;5;${FG5}m " | |
| OUT+="\e[38;5;${BG5}m\e[48;5;${BG6}m${SEP}" | |
| # Segment 6: Cost | |
| OUT+="\e[38;5;${FG6}m\e[48;5;${BG6}m ${ICO_COST} ${TOTAL_COST} " | |
| OUT+="\e[38;5;${BG6}m\e[48;5;${BG7}m${SEP}" | |
| # Segment 7: Time | |
| OUT+="\e[38;5;${FG7}m\e[48;5;${BG7}m ${ICO_TIME} ${CURRENT_TIME} " | |
| # Final transition → terminal default | |
| OUT+="\e[0m\e[38;5;${BG7}m${SEP}\e[0m" | |
| echo "${OUT}" |
Author
Jian-Min-Huang
commented
Mar 14, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment