Skip to content

Conversation

@AdamFo
Copy link

@AdamFo AdamFo commented Jan 22, 2026

Summary

Fixes statusline-command.sh to work correctly on WSL/Linux systems. Previously, the statusline displayed "STATUSLINE: Unknown" and "Context 0%" with multiple errors due to macOS-specific commands.

Issues resolved:

  • jq: command not found - documented as required dependency
  • stat: invalid option -- 'f' - macOS stat syntax incompatible with Linux
  • /dev/tty: No such device or address - TTY device inaccessible in hook contexts
  • integer expression expected - empty context_max variable

Changes

  1. Added cross-platform get_file_mtime() function

    • Detects OS using $OSTYPE
    • Uses stat -f %m on macOS, stat -c %Y on Linux
    • Replaces three hardcoded stat -f %m calls
  2. Fixed TTY detection for non-interactive contexts

    • Changed from /dev/tty file access to -t 0 (test if stdin is terminal)
    • Prevents errors when running in hook contexts where TTY is unavailable
  3. Added default value for context_max variable

    • Defaults to 0 when JSON input is empty/missing
    • Prevents bash arithmetic errors

Test plan

  • Tested on WSL2 Ubuntu 24.04 with Warp terminal
  • Verified statusline displays location, weather, context, and learning signals correctly
  • Confirmed no error messages in output
  • Needs verification on macOS to ensure no regression

Related issues

Note

jq is required for statusline to function. Consider adding to install documentation or install.ts dependency check.


Generated with Claude Code

Resolves statusline errors on WSL/Linux systems:

1. Add cross-platform get_file_mtime() function
   - Uses OSTYPE detection for stat command format
   - macOS: stat -f %m
   - Linux: stat -c %Y

2. Fix TTY detection for non-interactive contexts
   - Use -t 0 (test stdin is terminal) instead of /dev/tty
   - Prevents "No such device or address" errors in hooks

3. Add default value for context_max variable
   - Prevents "integer expression expected" errors
   - Defaults to 0 when JSON input is empty

Tested on WSL2 Ubuntu 24.04 with Warp terminal.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant