Show HN: 10 Lines of Python to fix mangled copy-paste from Claude Code Claude Code uses Ink (React for CLIs) which positions text via cursor moves. When you copy text from its terminal output, each line gets padded with trailing spaces to fill the terminal width, and every line gets a consistent leading indent from the UI chrome. The result is text that looks right in the terminal but pastes like garbage. I assumed this was a hard problem — that the copy operation was destroying line boundaries and merging padding with indentation into an ambiguous space blob. Nope. A hex dump (`pbpaste | xxd`) showed real `0a` newlines at every line boundary, and consistent leading whitespace. The entire fix is: strip trailing whitespace, dedent.
Usage:
Yes I know Clean Clode exists — but it's a web app. If I'm already in a terminal copying from a terminal, opening a browser to fix terminal output feels wrong (and not appropriate for anything sensitive). |
No comments yet