Skip to content

Pass terminalWidth in custom command stdin JSON #308

Closed

Description

@LZong-tw

Summary

Custom Command widgets receive context.data as JSON via stdin, but context.terminalWidth is not included. This makes it impossible for scripts to adapt output based on terminal width.

Current behavior

From the source (dist/ccstatusline.js:57125):

const jsonInput = JSON.stringify(context.data);
let output = execSync3(item.commandPath, {
  encoding: "utf8",
  input: jsonInput,
  // ...
});

context.terminalWidth exists but is not part of context.data, so custom commands can't access it. Standard detection methods (tput cols, stty size, $COLUMNS) all return 80 in the piped stdio context.

Proposed change

Include terminalWidth (or terminal_width) in the JSON passed to custom commands:

{
  "workspace": { "current_dir": "/path/..." },
  "model": { "display_name": "..." },
  "terminal_width": 142
}

Use case

Adaptive label display — show full labels ("ReadCache", "CacheCreate") on wide terminals and abbreviated ("RC", "CC") on narrow ones.

Workaround

Currently using full labels and relying on ccstatusline's own truncation ("..."), which is suboptimal on narrow screens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions