claude-code - 💡(How to fix) Fix [BUG] Commands in code blocks cannot be copy-pasted directly into terminal

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix / Workaround

Current workaround: ask Claude to write the command to a .ps1 file and run that — but this doesn't work for remote terminals like Azure Cloud Shell where local files aren't accessible.

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this is not a duplicate
  • This is a single bug report
  • I am using the latest version of Claude Code (2.1.150)

What's Wrong?

Shell commands rendered in Claude Code's TUI output cannot be copy-pasted directly into a terminal for two related reasons:

  1. Long commands wrap visually in the TUI output — selecting them with the mouse breaks across lines, making it impossible to copy a long command as a single line.

  2. Multiline commands (backslash continuations) paste line by line — when Claude formats a command across multiple lines using \ continuations, pasting into a terminal submits each line individually on Enter, causing the first fragment to execute immediately and fail.

The combination means there is no reliable way to copy a command from Claude Code output and run it in an external terminal (e.g. Cloud Shell, PowerShell, WSL) without manually editing it first.

What Should Happen?

Commands in code blocks should be copy-pasteable as-is into a terminal. Either:

  • A copy button on code blocks that copies the raw unwrapped text, or
  • Commands always rendered as single lines in code blocks (no \ continuations), or
  • Both

Steps to Reproduce

  1. Ask Claude to produce any az CLI command or other long shell command
  2. Claude renders it with \ line continuations across multiple lines in a code block
  3. Try to copy and paste into Windows Terminal / PowerShell / Cloud Shell
  4. First line executes immediately on paste, rest fail

Is this a regression?

No, never worked

Claude Code Version

2.1.150

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

Current workaround: ask Claude to write the command to a .ps1 file and run that — but this doesn't work for remote terminals like Azure Cloud Shell where local files aren't accessible.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING