Set Windows UTF-8 code page for piped statusline (closes #186)

This commit is contained in:
Matthew Breedlove
2026-02-21 14:20:55 -05:00
parent 2e0b321d41
commit 20691a70b0
+15
View File
@@ -54,6 +54,19 @@ async function readStdin(): Promise<string | null> {
}
}
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() !== '') {