diff --git a/src/ccstatusline.ts b/src/ccstatusline.ts index 0bc999d..6998ca3 100644 --- a/src/ccstatusline.ts +++ b/src/ccstatusline.ts @@ -54,6 +54,19 @@ async function readStdin(): Promise { } } +async function ensureWindowsUtf8CodePage() { + if (process.platform !== 'win32') { + return; + } + + try { + const { execFileSync } = await import('child_process'); + execFileSync('chcp.com', ['65001'], { stdio: 'ignore' }); + } catch { + // Ignore failures to preserve statusline output even in restricted shells. + } +} + async function renderMultipleLines(data: StatusJSON) { const settings = await loadSettings(); @@ -164,6 +177,8 @@ async function renderMultipleLines(data: StatusJSON) { async function main() { // Check if we're in a piped/non-TTY environment first if (!process.stdin.isTTY) { + await ensureWindowsUtf8CodePage(); + // We're receiving piped input const input = await readStdin(); if (input && input.trim() !== '') {