自訂ClaudeCode 的statusline,感受花錢的爽感! /statusline 指令設置,如需抄作業,我的腳本如下: #!/bin/bash # ========================================================================== # CLAUDE CODE STATUS PANEL - CYBERPUNK ASCII ART EDITION # ========================================================================== input=$(cat) # --[ DATA EXTRACTION ]------------------------------------------------------- cost=$(echo "$input" | jq -r '.cost.total_cost_usd // 0 | . * 100 | floor / 100') lines_add=$(echo "$input" | jq -r '.cost.total_lines_added // 0') lines_del=$(echo "$input" | jq -r '.cost.total_lines_removed // 0') api_ms=$(echo "$input" | jq -r '.cost.total_api_duration_ms // 0') model=$(echo "$input" | jq -r '.model.display_name // "—"') # --[ TIME FORMAT ]----------------------------------------------------------- api_s=$((api_ms / 1000)) # --[ ANSI COLOR CODES ]------------------------------------------------------------------ # Hermès 愛馬仕配色 BG_HERMES='\033[48;5;29m' FG_HERMES_GREEN='\033[38;5;29m' FG_HERMES_ORANGE='\033[38;5;208m' FG_WHITE='\033[38;5;255m' FG_BLACK='\033[38;5;232m' FG_GRAY='\033[38;5;245m' BOLD='\033[1m' RESET='\033[0m' # --[ CYBERPUNK ASCII PANEL ]------------------------------------------------- # 固定寬度26 字符 W=26 # --[ LINE 1: HEADER ]-- cwd_name=$(basename "$(echo "$input" | jq -r '.cwd // "CLAUDE"')") header=" ░░▒▒▓▓██${cwd_name}██▓▓▒▒░░ " header_len=${#header} pad=$((W - header_len)) printf "\n" printf "${BG_HERMES}${FG_BLACK}${BOLD}%s%*s${RESET}\n" "$header" $pad "" # --[ LINE 2: METRICS ]-- printf " ${FG_HERMES_ORANGE}💰 \$${cost}${RESET}" printf " ${FG_GRAY}│${RESET}" printf " ${FG_HERMES_GREEN}+${lines_add}${RESET} ${FG_HERMES_ORANGE}-${lines_del}${RESET}" printf " ${FG_GRAY}│${RESET}" printf " ${FG_WHITE}${model}${RESET}" printf "\n" # --[ LINE 3: FOOTER ]-- # 從transcript 檔案解析token 數據 transcript=$(echo "$input" | jq -r '.transcript_path // ""') if [[ -n "$transcript" && -f "$transcript" ]]; then in_tokens=$(jq -s '[.[] | select(.type == "assistant") | .message.usage.input_tokens // 0] | add // 0' "$transcript" 2>/dev/null) out_tokens=$(jq -s '[.[] | select(.type == "assistant") | .message.usage.output_tokens // 0] | add // 0' "$transcript" 2>/dev/null) in_tokens=${in_tokens:-0} out_tokens=${out_tokens:-0} else in_tokens=0 out_tokens=0 fi # 格式化函數 fmt_tokens() { local t=$1 if [[ $t -ge 1000000 ]]; then echo "$(echo "scale=1; $t / 1000000" | bc)M" elif [[ $t -ge 1000 ]]; then echo "$(echo "scale=1; $t / 1000" | bc)k" else echo "$t" fi } in_fmt=$(fmt_tokens $in_tokens) out_fmt=$(fmt_tokens $out_tokens) footer=" ░▒▓ ↑${in_fmt} ↓${out_fmt} ▓▒░ " footer_len=${#footer} pad_total=$((W - 腳_len)) pad_left=$((pad_total / 2)) pad_right=$((pad_total - pad_left)) printf "${BG_HERMES}${FG_BLACK}${BOLD}%*s%s%*s${RESET}\n" $pad_left "" "$footer" $pad_right ""
正在載入線程內容
正在從 X 取得原始推文,整理成清爽的閱讀畫面。
通常只需幾秒鐘,請稍候。
