Code-block rendering breaks terminal copy-paste for shell snippets
Summary
When the assistant produces shell commands in fenced code blocks for the user to paste into a terminal, several patterns degrade reliably enough that the conversation pattern itself adapts around them — the assistant ends up shipping throwaway scripts to source files and asking the user to deploy+run them, rather than providing a one-liner, even for trivial tasks.
Repro patterns observed in a real session
- Heredocs across multiple lines (e.g.
sudo tee /file >/dev/null <<EOF ... EOFfollowed by more commands). The EOF terminator and trailing lines often don't land cleanly when pasted; the multi-step sequence breaks.
- Long single-line commands with shell quoting and pipes (e.g.
ssh host \"echo '...' | sudo tee /file && cmd2 && cmd3\"). The line visually wraps in the renderer, and selection/copy frequently grabs only a wrapped fragment rather than the full logical line.
- Code blocks rendered with leading indentation (e.g. inside list items or nested in prose). The leading whitespace ends up in the clipboard; downstream shell behaviour varies, and in some configs (zsh/fish with comment-stripping) it breaks the command silently.
Impact
The assistant's own response patterns shift to work around this: rather than offering a paste-ready one-liner, it writes a small shell script into the source tree, asks the user to deploy it (which itself often involves the very paste flow that is broken), and then run it as root on the remote.
For tasks that should be a single shell line (e.g. dropping a /etc/sudoers.d/* file, creating a small env file with mode 640), this turns a 30-second exchange into a multi-step deploy cycle.
Suggested directions
- Render fenced code blocks with no leading indent regardless of surrounding markdown context.
- Per-block copy-to-clipboard affordance (helps screen-reader and mobile users too).
- For the assistant side: a documented preference the user can set (e.g. \"render shell snippets as single logical lines, avoid heredocs in pasted snippets\") that survives the formatting layer reliably.
Environment
Reported during a live session in Claude Code (TUI). User reports the same workflow does not exhibit the friction in opencode, suggesting the differentiator is in the renderer layer rather than in the assistant's text output itself.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗