Skip to content

Instantly share code, notes, and snippets.

@mikeplate
Last active August 25, 2026 06:37
Show Gist options
  • Select an option

  • Save mikeplate/4cfb949feac4e487b67a0e66baa7a6ce to your computer and use it in GitHub Desktop.

Select an option

Save mikeplate/4cfb949feac4e487b67a0e66baa7a6ce to your computer and use it in GitHub Desktop.
Claude Code CLI Status Line PowerShell Script
# Edit the following file in your user profile:
# ~/.claude/settings.json
#
# Add property statusLine to the existing json object in this file.
# You don't have to save the script file to your profile, just make sure the path is correct.
# {
# "statusLine": {
# "type": "command",
# "command": "powershell -NoProfile -File C:/Users/<username>/.claude/statusline-command.ps1"
# },
# }
#
# Save the rest of this file to the path you specified above
$jsonText = $null
try { $jsonText = [Console]::In.ReadToEnd() } catch {}
if (-not $jsonText) { exit 0 }
$model = ""
$effort = ""
$branch = ""
$ctx = ""
$reset = ""
$tokens = ""
try {
$data = $jsonText | ConvertFrom-Json
if ($data.model.display_name -and $data.model.display_name -ne "") {
$model = $data.model.display_name
} elseif ($data.model.id -and $data.model.id -ne "") {
$model = $data.model.id
}
if ($data.effort.level -and $data.effort.level -ne "") {
$effort = $data.effort.level
}
$cwd = $data.workspace.current_dir
if ($cwd -and (Test-Path $cwd)) {
$b = & git -C $cwd --no-optional-locks branch --show-current 2>$null
if ($LASTEXITCODE -eq 0) { $branch = $b }
}
$used_pct = $data.rate_limits.five_hour.used_percentage
if ($null -ne $used_pct) {
$ctx = "usage: $([math]::Round($used_pct, 0))%"
}
$used_pct = $data.rate_limits.seven_day.used_percentage
if ($null -ne $used_pct) {
$ctx += " ($([math]::Round($used_pct, 0))% w)"
}
$resets_at = $data.rate_limits.five_hour.resets_at
if ($null -ne $resets_at) {
$resetTime = [DateTimeOffset]::FromUnixTimeSeconds($resets_at).ToLocalTime().ToString("HH:mm")
$reset = "reset: $resetTime"
}
$resets_at_week = $data.rate_limits.seven_day.resets_at
if ($null -ne $resets_at_week) {
$resetTimeWeek = [DateTimeOffset]::FromUnixTimeSeconds($resets_at_week).ToLocalTime().ToString("yyyy-MM-dd HH:mm")
$reset += " ($resetTimeWeek)"
}
$used_input = $data.context_window.total_input_tokens
if ($null -ne $used_input) {
$tokens += "ctx i/o: $([math]::Round($used_input/1000, 0))k"
}
$used_output = $data.context_window.total_output_tokens
if ($null -ne $used_output) {
$tokens += " / $([math]::Round($used_output/1000, 0))k"
}
} catch {}
# Build output
$parts = @()
if ($model) { $parts += $model }
if ($effort) { $parts += $effort }
if ($branch) { $parts += $branch }
if ($ctx) { $parts += $ctx }
if ($reset) { $parts += $reset }
if ($tokens) { $parts += $tokens }
Write-Host ($parts -join " | ") -NoNewline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment