logo

Cleaner pastes from Claude with Raycast

Letting a small script handle the cleanup for me

Joel Clermont
Joel Clermont
2026-04-28

In yesterday's tip, I shared my quick fix for those two extra spaces that show up when copying text from Claude in the terminal.

That simple approach works great when I want everything Claude generated, but sometimes I only want a small piece. In that case, I'd rather select the part I want and copy it myself.

So I built a small Raycast script to clean it up on the way out. Here is the two-line script:

pbpaste | sed 's/^  //' | pbcopy
osascript -e 'tell application "System Events" to keystroke "v" using command down'

The first line pulls the clipboard, strips the leading two spaces from each line, and writes it back. The second line simulates Cmd+V into whatever app has focus.

You might wonder why not just call pbpaste again instead of simulating a keystroke. In a Raycast script, pbpaste writes to stdout with no terminal to receive it. The synthesized keystroke is what actually drops the text into the focused window.

Now I trigger the script with a hotkey and it cleans up whatever I just copied.

Here to help,

Joel

P.S. Have your own workflow tweaks for working with AI tools? Share them with other Laravel devs in the community.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice.