From 40b04f159eef5f7737b531cfd577c254967b1018 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 19 Feb 2026 11:23:53 -0800 Subject: [PATCH] Truncate prompt column in session list to fit terminal width --- src/cli.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index eaa1baf..1eb352a 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -175,10 +175,16 @@ program const branchWidth = Math.max(6, ...sessions.map((s) => s.branch.length)) const worktreeWidth = Math.max(8, ...sessions.map((s) => tilde(s.worktree).length + 1)) + const cols = process.stdout.columns || 80 + const prefixWidth = branchWidth + 2 + worktreeWidth + 2 + console.log(`${"BRANCH".padEnd(branchWidth)} ${"WORKTREE".padEnd(worktreeWidth)} PROMPT`) for (const s of sessions) { const wt = tilde(s.worktree) + "/" - console.log(`${s.branch.padEnd(branchWidth)} ${wt.padEnd(worktreeWidth)} ${s.prompt ?? ""}`) + const prompt = s.prompt ?? "" + const maxPrompt = cols - prefixWidth + const truncated = maxPrompt > 3 && prompt.length > maxPrompt ? prompt.slice(0, maxPrompt - 3) + "..." : prompt + console.log(`${s.branch.padEnd(branchWidth)} ${wt.padEnd(worktreeWidth)} ${truncated}`) } })