Skip to content

Conversation

@ItsDaRa
Copy link

@ItsDaRa ItsDaRa commented Dec 25, 2025

Summary

  • Adds Windows platform check to getTerminalWidth() and canDetectTerminalWidth() in src/utils/terminal.ts
  • Uses process.stdout.columns on Windows instead of Unix-only shell commands

Problem

On Windows, the current terminal width detection causes issues:

  • tput command doesn't exist
  • ps, stty, awk are Unix-only utilities
  • Shell redirect 2>/dev/null creates a literal file named "null" in the working directory instead of suppressing stderr

This results in spurious "null" files being created wherever Claude Code is run.

Solution

Added a platform check at the start of both functions:

if (process.platform === 'win32') {
    const cols = process.stdout.columns;
    // return width or null/boolean as appropriate
}

process.stdout.columns is the Node.js cross-platform API for terminal width and works reliably on Windows.

Test plan

  • Tested on Windows 11 - no more "null" files created
  • Terminal width detection works correctly
  • Unix behavior unchanged (early return on Windows means Unix code path untouched)

Fixes #117

🤖 Generated with Claude Code

On Windows, the Unix-specific commands (ps, stty, tput) and shell
redirects (2>/dev/null) don't work and cause issues:
- tput doesn't exist on Windows
- 2>/dev/null creates a literal file named "null" instead of
  redirecting stderr

This fix adds a platform check at the start of getTerminalWidth()
and canDetectTerminalWidth() to use process.stdout.columns on
Windows, which is the cross-platform Node.js API for this purpose.

Fixes sirmalloc#117

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@sirmalloc
Copy link
Owner

@ItsDaRa Have you tested this and seen the terminal width return appropriately on Windows? The main issue has always been that Claude Code calls the statusline as a subprocess without an actual connection to the terminal Claude Code is running in, so typical width detection always returns 80. If you can verify this by adding the "terminal width" widget to your statusline and resizing the terminal and verify it updates properly, then I'll merge this and push a new build out. I don't currently have a Windows machine easily accessible.

@ItsDaRa
Copy link
Author

ItsDaRa commented Jan 9, 2026

Apologizes, I didn't get any sort of notification. I'll try to test it in the next days and get back to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: tput cols creates "null" file and fails terminal width detection

2 participants