Skip to content

feat(tui): format shell commands for readability - #47798

Closed
kerrnelPanic wants to merge 1 commit into
anomalyco:devfrom
kerrnelPanic:format-shell-commands
Closed

kerrnelPanic wants to merge 1 commit into
anomalyco:devfrom
kerrnelPanic:format-shell-commands

Conversation

@kerrnelPanic

@kerrnelPanic kerrnelPanic commented Sep 7, 2026 •

Copy link
Copy Markdown

Issue for this PR

References #38526

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Long shell commands with pipes, semicolons, and &&/|| chains wrap mid-token at the terminal edge, making them hard to read in the permission prompt and session view.

This adds a formatShellCommand() utility that inserts line breaks at top-level shell operators (;, |, &&, ||, ;;, |&) when a command exceeds 60 characters. It's quote-aware (won't split inside single/double quotes, backticks), and also respects shell comments, heredoc bodies, and arithmetic expansion $((...)). Continuation lines are indented two spaces.

Applied in two places:

  • Permission prompt (permission.tsx)
  • Session tool display (index.tsx, Shell component)

How did you verify your code works?

Tested 13 edge cases including quoted operators, backticks, heredocs, arithmetic expansion, comments, escaped operators, pre-existing newlines, and the full compound command from the screenshots. Typecheck passes (no new errors).

Screenshots / recordings

Before — command wraps mid-token at terminal edge:

Screenshot 2026-09-07 150656

After — command split at shell operators with 2-space indent:

Screenshot 2026-09-07 150259

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@dotSource-bke

Copy link
Copy Markdown

Rebased onto latest dev (v1.18.30 + unreleased). No content changes — same single feature commit, updated base.

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants