From 6cb12d42dfc43c3e5ce1fde971e52afeb4c84099 Mon Sep 17 00:00:00 2001 From: Michael Kent Date: Mon, 30 Mar 2026 21:11:52 -0500 Subject: [PATCH] fix: shorten model name and token count display --- statusline.ps1 | 7 ++++++- statusline.sh | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/statusline.ps1 b/statusline.ps1 index ea2c57d..61beab0 100644 --- a/statusline.ps1 +++ b/statusline.ps1 @@ -25,7 +25,11 @@ $reset = "${esc}[0m" # Format token counts (e.g., 50k / 200k) function Format-Tokens([long]$num) { - if ($num -ge 1000000) { return "{0:F1}m" -f ($num / 1000000) } + if ($num -ge 1000000) { + $val = [math]::Round($num / 1000000, 1) + if ([math]::Abs($val - [math]::Round($val)) -lt 0.05) { return "{0:F0}m" -f $val } + return "{0:F1}m" -f $val + } elseif ($num -ge 1000) { return "{0:F0}k" -f ($num / 1000) } else { return "$num" } } @@ -63,6 +67,7 @@ function Test-VersionGreaterThan([string]$a, [string]$b) { $data = $input | ConvertFrom-Json $modelName = if ($data.model.display_name) { $data.model.display_name } else { "Claude" } +$modelName = ($modelName -replace '\s*\((\d+\.?\d*[kKmM])\s+context\)', ' $1').Trim() # "(1M context)" → "1M" # Context window $size = if ($data.context_window.context_window_size) { [long]$data.context_window.context_window_size } else { 200000 } diff --git a/statusline.sh b/statusline.sh index 8d78f37..791c74b 100755 --- a/statusline.sh +++ b/statusline.sh @@ -26,7 +26,7 @@ reset='\033[0m' format_tokens() { local num=$1 if [ "$num" -ge 1000000 ]; then - awk "BEGIN {printf \"%.1fm\", $num / 1000000}" + awk "BEGIN {v=sprintf(\"%.1f\",$num/1000000)+0; if(v==int(v)) printf \"%dm\",v; else printf \"%.1fm\",v}" elif [ "$num" -ge 1000 ]; then awk "BEGIN {printf \"%.0fk\", $num / 1000}" else @@ -70,6 +70,7 @@ version_gt() { } # ===== Extract data from JSON ===== model_name=$(echo "$input" | jq -r '.model.display_name // "Claude"') +model_name=$(echo "$model_name" | sed 's/ *(\([0-9.]*[kKmM]*\) context)/ \1/') # "(1M context)" → "1M" # Context window size=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')