request: Pass available width(s) to statusLine command hook

Status Closed — not planned
Maintainer reply None cached
Activity 10 comments · opened Aug 9, 2025 · closed Jan 18, 2026

Bug Description
I would like to use the current terminal width to right justify some information in the statusLine command.

However, $COLUMNS is not set, and tput cols always ruturns 80 when run inside Claude Code.

Can we have the current terminal width made available to that command?

Updated request, after more experience:

It appears that the statusLine command output does not have availble the entire width of the terminal.
1- There are ~2 spaces on the left and right for padding.
2- When Claude Code shows messages like "Approaching limit", this takes up columns on the right, reducing significantly the width that statusLine command has available.

This should really be a feature request (not a bug), asking for the statusLine JSON to include the entire width currently available to the lines(s) output.

If there may be situations where different lines have different widths available, please include that information as well.

Note: Thanks! and I love the statusLine command feature!

In case it's not obvious, I'm talking about this in ~/.claude/settings.json:

  "statusLine": {
    "type": "command",
    "command": "~/bin/claudecode-statusline"
  }

Environment Info

  • Platform: linux
  • Terminal: gnome-terminal
  • Version: 1.0.72
  • Feedback ID: 9bb0af8a-2729-4a68-8de7-e755679f1036

View original on GitHub ↗

10 Comments

ehammond · 1 year ago

heh. Claude Code (Opus 4.1) hopes that Claude Code will someday add it to the JSON. It imagined this optimistic vision of the future just based on me telling it that tput cols did not work. (and this happened before I submitted this /bug report in a different instance of Claude Code.)

I wrote:

tput cols always says 80 inside Claude Code

Claude Code worked then reported back:

````
[...]
● Updated the script to handle the tput cols limitation. It now:

  1. First checks if Claude Code provides terminal_width in the JSON (in case they add it in the future)
  2. Falls back to a reasonable default of 120 columns if not provided
sirmalloc · 1 year ago

I've got a bit of a 'hack' for this that works on POSIX compliant systems over in ccstatusline.ts that grabs it from the parent process using stty. The bigger issue is even with the correct width, rendering can be thrown off by their IDE integration features (showing filename, total lines selected) or their auto-compact message. One workaround is subtract 40 off of it, but then it leaves things looking weird.

I added a hacky workaround to that in ccstatusline that keeps it fully right aligned until the context percentage reaches the auto-compact threshold, but I still don't really like the solution. You can give it a try usingnpx ccstatusline and grab the code if it works for your needs. I've requested via /bug that they add the usable terminal width to the JSON. So fingers crossed.

github-actions[bot] · 1 year ago

---

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5202
  2. https://github.com/anthropics/claude-code/issues/5408
  3. https://github.com/anthropics/claude-code/issues/2444

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

ehammond · 1 year ago

I don't think this is a duplicate of those issues.

  • inheriting a variable is no longer sufficient to calculate the available width(s) on the status lines
  • this request is not related to any crashing
  • this is not related the Bash tool
alvis · 1 year ago

seems like the issue is that no env variables are passed to CC. Maybe it's for security reason, but it makes status line less useful

github-actions[bot] · 10 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

gmnistasia-beep · 10 months ago

Adding another data point: experiencing this on Windows 11 with both PowerShell and Git Bash.

Environment:

  • Claude Code 2.0.73
  • Windows 11
  • Both PowerShell 7 and Git Bash (MINGW64)
  • Window snapped to half-screen width

Findings:

  • tput cols returns 80 regardless of actual window size
  • stty size fails entirely on Windows
  • Node.js process.stdout.columns returns undefined
  • $COLUMNS environment variable is empty/unset

Impact: Text rendering corruption - characters missing, lines truncating mid-word. Makes Claude Code difficult to use on Windows with any terminal wider than 80 columns.

This is blocking productive use. Would love to see a fix or at minimum a config option to manually set terminal width.

github-actions[bot] · 8 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

marcindulak · 8 months ago

This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.

github-actions[bot] · 8 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.