mirror of
https://github.com/tiennm99/ccstatusline.git
synced 2026-07-18 22:16:50 +00:00
Set Windows UTF-8 code page for piped statusline (closes #186)
This commit is contained in:
@@ -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() !== '') {
|
||||
|
||||
Reference in New Issue
Block a user