frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: 10 Lines of Python to fix mangled copy-paste from Claude Code

1•collectedparts•1h ago
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.

  #!/usr/bin/env python3
  import re, sys

  def clean(text):
      text = re.sub(r'\x1b\[[0-9;]*[a-zA-Z]', '', text)     # strip ANSI escapes
      text = re.sub(r'\x1b\][^\x07]*\x07', '', text)         # strip OSC sequences
      text = re.sub(r'[ \t]+$', '', text, flags=re.MULTILINE) # strip trailing whitespace
      lines = text.split('\n')
      while lines and not lines[0].strip(): lines.pop(0)     # drop leading blank lines
      while lines and not lines[-1].strip(): lines.pop()     # drop trailing blank lines
      indent = min((len(l) - len(l.lstrip()) for l in lines if l.strip()), default=0)
      return '\n'.join(l[indent:] for l in lines) + '\n'

  print(clean(sys.stdin.read()), end='')
Usage:

    pbpaste | ./unfuck-paste
    pbpaste | ./unfuck-paste | pbcopy   # fix in-place on clipboard
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).

Is 50% discount for launch a good idea?

1•eddiejaoude•59s ago•0 comments

Switching from Spotify to Apple Music: Notes on a Surprisingly Bad Desktop UX

https://twitter.com/nicbarkeragain/status/2037328601683841509
1•dsego•2m ago•0 comments

Jury finds Meta, YouTube liable for social media addiction: What we know

https://www.aljazeera.com/news/2026/3/26/jury-finds-meta-youtube-liable-for-social-media-addictio...
1•dalvrosa•3m ago•0 comments

AI Optimizer – OpenAI API Caching Proxy (20-40% Cost Savings)

https://github.com/adamday75/ai-optimizer-app/releases/tag/v2.0.0
1•adamday75•6m ago•0 comments

Borne by Pilotwings

https://objkt.com/collections/KT1QLxw1JiAB2ZNWQu5vsqNoc5eqfyg9DX9q
1•bpierre•9m ago•0 comments

Anthropic tweaks timed usage limits to discourage demand during peak hours

https://www.theregister.com/2026/03/26/anthropic_tweaks_usage_limits/
1•pseudolus•11m ago•0 comments

I Can't See Apple's Vision

https://matduggan.com/i-cant-see-apples-vision/
1•carlesfe•13m ago•0 comments

Quantum experiment shows events may have no fixed order

https://phys.org/news/2026-03-quantum-events.html
1•pseudolus•13m ago•0 comments

The Listener

https://www.brainbun.com/blog/the-listener/
1•brainbun•15m ago•0 comments

CIS AWS v3.0: Automate Compliance with Terraform

https://haitmg.pl/blog/cis-aws-benchmark-automation/
1•gebalamariusz•16m ago•0 comments

the html review 05

https://thehtml.review/05/
1•keepamovin•18m ago•0 comments

More Students Use AI for Homework, and More Believe It Harms Critical Thinking

https://www.rand.org/pubs/research_reports/RRA4742-1.html
1•the-mitr•18m ago•0 comments

CSV to Transformer, via Bayesian Networks

https://github.com/area9innovation/bp2transformer
2•asgeralstrup•24m ago•1 comments

Interview with John Earnest

https://alexalejandre.com/programming/interview-with-john-earnest/
1•tosh•24m ago•0 comments

An Open-World Engine for the N64

https://www.youtube.com/watch?v=lXxmIw9axWw
1•QuantumNomad_•24m ago•0 comments

The illusion of illusions: There are no optical corrections in the Parthenon

https://arxiv.org/abs/2510.16831
2•geox•27m ago•0 comments

Ralphex: Write a Plan. Walk Away

https://ralphex.com/
1•souvlakee•28m ago•0 comments

Chicago Kare by Duane King

https://chicagokare.xyz/
1•keepamovin•28m ago•0 comments

microui: A tiny immediate-mode UI library

https://github.com/rxi/microui
1•tosh•30m ago•0 comments

Trump Administration Plans to Require Higher Wages for H-1B Visa Holders

https://www.wsj.com/politics/policy/trump-administration-plans-to-require-higher-wages-for-h-1b-v...
2•cebert•30m ago•0 comments

How I vibe-code 10 web services from anywhere

https://www.blynt.com/blog/vibe-coding-from-everywhere/
2•blynt•31m ago•0 comments

How I work without a mouse

https://plo.fyi/blog/working-without-a-mouse/
1•ploMP4•31m ago•0 comments

Druids: Batteries-included library to coordinate and deploy coding agents

https://druids.dev/welcome
2•isaacimagine•32m ago•0 comments

(A Few) Ops Lessons We All Learn the Hard Way

https://netmeister.org/blog/ops-lessons.html
1•rayhaanj•33m ago•0 comments

It's 2026 and infrastructure DevEx is still lacking

https://grafosai.substack.com/p/its-2026-and-infrastructure-devex
1•souvlakius•34m ago•0 comments

I Think Software Development Will Be Automated by 2030

https://blog.vtemian.com/talk/will-ai-automate-the-sdlc-by-2030/
1•vtemian•35m ago•2 comments

Stripe builds interactive docs with Markdoc

https://stripe.dev/blog/markdoc
2•cezarvil•38m ago•0 comments

Spawning VMs for unreasonable workloads (2024)

https://blog.davidv.dev/posts/abusing-firecracker/
1•tlar•38m ago•0 comments

Claude API Error: 529

5•anujbans•39m ago•3 comments

How to Setup Pie for PHP Extensions on macOS

https://stephenjude.me/articles/how-to-setup-pie-for-php-extensions-on-macos
1•stehenjude•40m ago•0 comments