request: Pass available width(s) to statusLine command hook
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
10 Comments
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 colsdid not work. (and this happened before I submitted this /bug report in a different instance of Claude Code.)I wrote:
Claude Code worked then reported back:
````
[...]
● Updated the script to handle the tput cols limitation. It now:
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 using
npx ccstatuslineand 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.---
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
I don't think this is a duplicate of those issues.
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
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.
Adding another data point: experiencing this on Windows 11 with both PowerShell and Git Bash.
Environment:
Findings:
tput colsreturns 80 regardless of actual window sizestty sizefails entirely on Windowsprocess.stdout.columnsreturnsundefined$COLUMNSenvironment variable is empty/unsetImpact: 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.
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.
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.
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.