Merge branch 'lets-add'
This commit is contained in:
commit
eb5acc2049
21
src/cli.ts
21
src/cli.ts
|
|
@ -251,18 +251,33 @@ program
|
|||
return
|
||||
}
|
||||
|
||||
const icons: Record<string, string> = { idle: "◌", active: "◯", dirty: "◎", saved: "●" }
|
||||
const reset = "\x1b[0m"
|
||||
const dim = "\x1b[2m"
|
||||
const bold = "\x1b[1m"
|
||||
const green = "\x1b[32m"
|
||||
const yellow = "\x1b[33m"
|
||||
const cyan = "\x1b[36m"
|
||||
const white = "\x1b[37m"
|
||||
|
||||
const icons: Record<string, string> = { idle: `${dim}◌${reset}`, active: `${green}◯${reset}`, dirty: `${yellow}◎${reset}`, saved: `${cyan}●${reset}` }
|
||||
const branchColors: Record<string, string> = { idle: dim, active: green, dirty: yellow, saved: cyan }
|
||||
const branchWidth = Math.max(6, ...sessions.map((s) => s.branch.length))
|
||||
const cols = process.stdout.columns || 80
|
||||
const prefixWidth = branchWidth + 4
|
||||
|
||||
console.log(` ${dim}${"BRANCH".padEnd(branchWidth)} PROMPT${reset}`)
|
||||
|
||||
for (const s of sessions) {
|
||||
const prompt = s.prompt ?? ""
|
||||
const icon = icons[statuses[s.branch]]
|
||||
const status = statuses[s.branch]
|
||||
const icon = icons[status]
|
||||
const bc = branchColors[status]
|
||||
const maxPrompt = cols - prefixWidth
|
||||
const truncated = maxPrompt > 3 && prompt.length > maxPrompt ? prompt.slice(0, maxPrompt - 3) + "..." : prompt
|
||||
console.log(`${icon} ${s.branch.padEnd(branchWidth)} ${truncated}`)
|
||||
console.log(`${icon} ${bc}${s.branch.padEnd(branchWidth)}${reset} ${dim}${truncated}${reset}`)
|
||||
}
|
||||
|
||||
console.log(`\n${dim}◌ idle${reset} · ${green}◯ active${reset} · ${yellow}◎ unsaved${reset} · ${cyan}● saved${reset}`)
|
||||
})
|
||||
|
||||
// ── sandlot open <branch> ─────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user