Copying text from CLI output includes trailing spaces to end of terminal width
Description
When copying text from Claude Code CLI output, each line includes trailing spaces all the way to the terminal width, even after the last visible character. This makes the copied text difficult to manipulate in other applications.
Steps to Reproduce
- Run Claude Code in terminal
- Get some output (code, markdown, any text)
- Select and copy a portion of the output
- Paste into another application (text editor, browser, etc.)
- Observe that each line has trailing spaces padding it to the full terminal width
Expected Behavior
Copied text should only include the actual content, with no trailing whitespace after the last real character on each line.
Actual Behavior
Example - what gets copied (· represents space):
const foo = "bar";····················································
function test() {·····················································
return true;························································
}·····································································
Environment
- Claude Code version: 2.1.x
- Platform: Windows 11 + WSL2
- Terminal: VS Code integrated terminal / Windows Terminal
Impact
High - Every time you copy code or text from Claude Code output, you need to manually trim trailing whitespace before using it elsewhere. This is especially painful when:
- Pasting into code editors (triggers whitespace linting errors)
- Pasting into chat/email (formatting issues)
- Pasting into forms or other applications
- Doing further text processing
Workaround
Currently need to paste into an editor and run "trim trailing whitespace" command, or use a regex to clean up. Very tedious for frequent copy operations.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗