时政
财经
科技
虚拟货币
其他
登录
#statusline
关注
赵纯想
1个月前
自定义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 - footer_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 ""
AI编程工具激战:Claude Code、Gemini Cli崛起· 1256 条信息
#ClaudeCode
#statusline
#自定义
#消费
#赛博朋克
分享
评论 0
0
面条
4个月前
只需要在 ~/.claude/settings.json 加入下面的配置,就可以看你 Claude Code 的实时消耗了 { "statusLine": { "type": "command", "command": "bun x ccusage statusline", // Use "npx -y ccusage statusline" if you prefer npm "padding": 0 // Optional: set to 0 to let status line go to edge } }
AI编程工具激战:Claude Code、Gemini Cli崛起· 1256 条信息
#Claude Code
#实时消耗
#ccusage
#statusline
#配置
分享
评论 0
0
个人主页
通知
我的投稿
我的关注
我的拉黑
我的评论
我的点赞