Guest User

claude code statusline

a guest
Feb 7th, 2026
2,172
1
Never
17
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.53 KB | None | 1 0
  1. # Claude Code StatusLine Script
  2. # Line 1: Model | tokens used/total | % used <fullused> | % remain <fullremain> | thinking status: on/off
  3. # Line 2: Current (5h): <progressbar> | Weekly (7d): <progressbar>
  4. # Line 3: reset: Current | reset: Weekly | reset: Monthly
  5.  
  6. try {
  7. $inputText = $input | Out-String
  8. if (-not $inputText) {
  9. $inputText = [Console]::In.ReadToEnd()
  10. }
  11.  
  12. [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
  13.  
  14. if ($inputText) {
  15. $json = $inputText | ConvertFrom-Json
  16.  
  17. # Model name
  18. $modelName = $json.model.display_name
  19. if (-not $modelName) { $modelName = "Claude" }
  20.  
  21. # ANSI escape character
  22. $e = [char]27
  23.  
  24. # Colors matching oh-my-posh theme
  25. $blue = "$e[38;2;0;153;255m"
  26. $orange = "$e[38;2;255;176;85m"
  27. $green = "$e[38;2;0;160;0m"
  28. $cyan = "$e[38;2;46;149;153m"
  29. $red = "$e[38;2;255;85;85m"
  30. $yellow = "$e[38;2;230;200;0m"
  31. $dim = "$e[2m"
  32. $reset = "$e[0m"
  33.  
  34. # Format token counts (e.g., 50k / 200k)
  35. function Format-Tokens($num) {
  36. if ($num -ge 1000000) { return [math]::Round($num / 1000000, 1).ToString() + "m" }
  37. elseif ($num -ge 1000) { return [math]::Round($num / 1000, 0).ToString() + "k" }
  38. else { return $num.ToString() }
  39. }
  40.  
  41. # Build a colored progress bar
  42. function Build-Bar($pct, $width) {
  43. if ($pct -lt 0) { $pct = 0 }
  44. if ($pct -gt 100) { $pct = 100 }
  45. $filled = [math]::Round($pct * $width / 100)
  46. $empty = $width - $filled
  47.  
  48. # Color based on usage level
  49. if ($pct -ge 90) { $barColor = $red }
  50. elseif ($pct -ge 70) { $barColor = $yellow }
  51. elseif ($pct -ge 50) { $barColor = $orange }
  52. else { $barColor = $green }
  53.  
  54. $filledStr = ""
  55. $emptyStr = ""
  56. if ($filled -gt 0) { $filledStr = [string]::new([char]0x25CF, $filled) }
  57. if ($empty -gt 0) { $emptyStr = [string]::new([char]0x25CB, $empty) }
  58.  
  59. return "${barColor}${filledStr}${dim}${emptyStr}${reset}"
  60. }
  61.  
  62. # Token calculations - default to 0 if no usage data
  63. $size = [int]($json.context_window.context_window_size)
  64. if ($size -eq 0) { $size = 200000 } # Default context size
  65.  
  66. $usage = $json.context_window.current_usage
  67. if ($usage) {
  68. $inputTokens = [int]($usage.input_tokens)
  69. $cacheCreate = [int]($usage.cache_creation_input_tokens)
  70. $cacheRead = [int]($usage.cache_read_input_tokens)
  71. $current = $inputTokens + $cacheCreate + $cacheRead
  72. } else {
  73. $current = 0
  74. }
  75.  
  76. $usedTokens = Format-Tokens $current
  77. $totalTokens = Format-Tokens $size
  78.  
  79. if ($size -gt 0) {
  80. $pctUsed = [math]::Round(($current / $size) * 100)
  81. } else {
  82. $pctUsed = 0
  83. }
  84. $pctRemain = 100 - $pctUsed
  85.  
  86. # Check thinking status from settings file
  87. $thinkingOn = $false
  88. $settingsPath = "$env:USERPROFILE\.claude\settings.json"
  89. if (Test-Path $settingsPath) {
  90. $settings = Get-Content $settingsPath -Raw | ConvertFrom-Json
  91. $thinkingOn = ($settings.alwaysThinkingEnabled -eq $true)
  92. }
  93.  
  94. # ===== LINE 1: Model | tokens | % used | % remain | thinking =====
  95. $line1 = "$blue$modelName$reset"
  96. $line1 += " $dim|$reset "
  97. $line1 += "$orange$usedTokens / $totalTokens$reset"
  98. $line1 += " $dim|$reset "
  99. $usedComma = $current.ToString("N0")
  100. $remainComma = ($size - $current).ToString("N0")
  101. $line1 += "$green$pctUsed% used ${orange}$usedComma$reset"
  102. $line1 += " $dim|$reset "
  103. $line1 += "$cyan$pctRemain% remain ${blue}$remainComma$reset"
  104. $line1 += " $dim|$reset "
  105. $line1 += "thinking: "
  106. if ($thinkingOn) {
  107. $line1 += "${orange}On$reset"
  108. } else {
  109. $line1 += "${dim}Off$reset"
  110. }
  111.  
  112. # ===== LINE 2: Usage limits with progress bars (cached) =====
  113. $cacheFile = "$env:TEMP\claude-statusline-usage-cache.json"
  114. $cacheMaxAge = 60 # seconds between API calls
  115.  
  116. $usageData = $null
  117. $needsRefresh = $true
  118.  
  119. # Check cache
  120. if (Test-Path $cacheFile) {
  121. $cacheAge = ((Get-Date) - (Get-Item $cacheFile).LastWriteTime).TotalSeconds
  122. if ($cacheAge -lt $cacheMaxAge) {
  123. $needsRefresh = $false
  124. try {
  125. $usageData = Get-Content $cacheFile -Raw | ConvertFrom-Json
  126. } catch {
  127. $needsRefresh = $true
  128. }
  129. }
  130. }
  131.  
  132. # Fetch fresh data if cache is stale
  133. if ($needsRefresh) {
  134. try {
  135. $credsPath = "$env:USERPROFILE\.claude\.credentials.json"
  136. if (Test-Path $credsPath) {
  137. $creds = Get-Content $credsPath -Raw | ConvertFrom-Json
  138. $token = $creds.claudeAiOauth.accessToken
  139. $headers = @{
  140. 'Accept' = 'application/json'
  141. 'Content-Type' = 'application/json'
  142. 'Authorization' = "Bearer $token"
  143. 'anthropic-beta' = 'oauth-2025-04-20'
  144. 'User-Agent' = 'claude-code/2.1.34'
  145. }
  146. $response = Invoke-RestMethod -Uri 'https://api.anthropic.com/api/oauth/usage' -Headers $headers -Method Get -TimeoutSec 5
  147. $usageData = $response
  148. # Write cache
  149. $response | ConvertTo-Json -Depth 5 | Set-Content $cacheFile -Force
  150. }
  151. } catch {
  152. # Silently fail - use stale cache if available
  153. if (Test-Path $cacheFile) {
  154. try { $usageData = Get-Content $cacheFile -Raw | ConvertFrom-Json } catch {}
  155. }
  156. }
  157. }
  158.  
  159. # Format ISO reset time to compact local time
  160. function Format-ResetTime($isoString, $style) {
  161. if (-not $isoString) { return "" }
  162. try {
  163. $utc = [DateTimeOffset]::Parse($isoString)
  164. $local = $utc.ToLocalTime()
  165. if ($style -eq "time") {
  166. return $local.ToString("h:mmtt").ToLower()
  167. } elseif ($style -eq "datetime") {
  168. return $local.ToString("MMM d, h:mmtt").ToLower()
  169. }
  170. return $local.ToString("MMM d").ToLower()
  171. } catch { return "" }
  172. }
  173.  
  174. # Pad visible text to a fixed column width (ignoring ANSI codes)
  175. function Pad-Column($text, $visibleLen, $colWidth) {
  176. $padding = $colWidth - $visibleLen
  177. if ($padding -gt 0) { return $text + (" " * $padding) }
  178. return $text
  179. }
  180.  
  181. $white = "$e[38;2;220;220;220m"
  182. $sep = " $dim|$reset "
  183.  
  184. $line2 = ""
  185. $line3 = ""
  186. if ($usageData) {
  187. $barWidth = 10
  188. $col1w = 23
  189. $col2w = 22
  190.  
  191. # ---- 5-hour (current) ----
  192. $fiveHourPct = 0; $fiveHourReset = ""
  193. if ($usageData.five_hour -and $null -ne $usageData.five_hour.utilization) {
  194. $fiveHourPct = [math]::Round([double]$usageData.five_hour.utilization)
  195. $fiveHourReset = Format-ResetTime $usageData.five_hour.resets_at "time"
  196. }
  197. $fiveHourBar = Build-Bar $fiveHourPct $barWidth
  198. # visible: "current: ●●●●●●●●●● 100%" = 9+10+1+4 = 24 max
  199. $col1BarVis = "current: " + ("x" * $barWidth) + " ${fiveHourPct}%"
  200. $col1Bar = "${white}current:$reset $fiveHourBar ${cyan}${fiveHourPct}%$reset"
  201. $col1Bar = Pad-Column $col1Bar $col1BarVis.Length $col1w
  202. # reset line
  203. $col1Reset = "resets $fiveHourReset"
  204. $col1ResetColored = "${white}resets $fiveHourReset$reset"
  205. $col1ResetColored = Pad-Column $col1ResetColored $col1Reset.Length $col1w
  206.  
  207. # ---- 7-day (weekly) ----
  208. $sevenDayPct = 0; $sevenDayReset = ""
  209. if ($usageData.seven_day -and $null -ne $usageData.seven_day.utilization) {
  210. $sevenDayPct = [math]::Round([double]$usageData.seven_day.utilization)
  211. $sevenDayReset = Format-ResetTime $usageData.seven_day.resets_at "datetime"
  212. }
  213. $sevenDayBar = Build-Bar $sevenDayPct $barWidth
  214. $col2BarVis = "weekly: " + ("x" * $barWidth) + " ${sevenDayPct}%"
  215. $col2Bar = "${white}weekly:$reset $sevenDayBar ${cyan}${sevenDayPct}%$reset"
  216. $col2Bar = Pad-Column $col2Bar $col2BarVis.Length $col2w
  217. $col2Reset = "resets $sevenDayReset"
  218. $col2ResetColored = "${white}resets $sevenDayReset$reset"
  219. $col2ResetColored = Pad-Column $col2ResetColored $col2Reset.Length $col2w
  220.  
  221. # ---- Extra usage ----
  222. $col3Bar = ""; $col3ResetColored = ""
  223. if ($usageData.extra_usage -and $usageData.extra_usage.is_enabled) {
  224. $extraPct = [math]::Round([double]$usageData.extra_usage.utilization)
  225. $extraUsed = [math]::Round([double]$usageData.extra_usage.used_credits / 100, 2)
  226. $extraLimit = [math]::Round([double]$usageData.extra_usage.monthly_limit / 100, 2)
  227. $extraBar = Build-Bar $extraPct $barWidth
  228. $nextMonth = (Get-Date).AddMonths(1)
  229. $extraReset = (Get-Date -Year $nextMonth.Year -Month $nextMonth.Month -Day 1).ToString("MMM d").ToLower()
  230.  
  231. $col3Bar = "${white}extra:$reset $extraBar ${cyan}`$$extraUsed/`$$extraLimit$reset"
  232. $col3ResetColored = "${white}resets $extraReset$reset"
  233. }
  234.  
  235. # Assemble line 2: bars row
  236. $line2 = $col1Bar + $sep + $col2Bar
  237. if ($col3Bar) { $line2 += $sep + $col3Bar }
  238.  
  239. # Assemble line 3: resets row
  240. $line3 = $col1ResetColored + $sep + $col2ResetColored
  241. if ($col3ResetColored) { $line3 += $sep + $col3ResetColored }
  242. }
  243.  
  244. # Output all lines
  245. [Console]::Write($line1)
  246. if ($line2) { [Console]::Write("`n$line2") }
  247. if ($line3) { [Console]::Write("`n$line3") }
  248. } else {
  249. [Console]::Write("Claude")
  250. }
  251. } catch {
  252. [Console]::Write("Claude | Error: $_")
  253. }
  254.  
Advertisement
Comments
  • armujahid
    265 days
    # text 0.11 KB | 0 0
    1. Thanks. I have generated bash script for Linux https://gist.github.com/armujahid/3b5d4fa0de358e9bc3d472015e0fa3ba
  • User was banned
  • User was banned
  • User was banned
    • Anexgohan
      243 days (edited)
      # text 0.12 KB | 0 0
      1. You are a dumb moron, don't claim stolen for my original work.
      2. And Stop plugging your shitty scam telegram channel everywhere.
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Ovsadpo
    1 day
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=zeaqtvqsgl
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment