Correctly Paste Multiline text into chat or composer (e.g. from Raycast)

As you know in Cursor when you past multi line text into Cursor it makes it a “pill” or what they call it. For me it is annoying if am pasting text or errors - anything not code. You can of course just accept it, or you can make it into a single line text before pasting it.

I am very dependent on Raycast on my mac and the Raycast clipboard history.
Extending the clipboard history with an action that converts it into a single line would be nice, but then you need to fork the whole thing.

Let’s try a different approach. let’s create a shell script since Raycast is designed to work well with shell scripts, using raycast script commands:

  1. Open the Extensions tab in the Raycast preferences
  2. Click the plus button
  3. Click Add Script Directory
  4. Select directories containing your Script Commands
  5. Copy my script to the folder you just selected,
  6. Save it as clipboard-to-single-line.sh
  7. Make it executable: chmod +x clipboard-to-single-line.sh
  8. Reload Raycast
  9. Add hotkey in raycast, for example option+cmd+v

Now copy text as normally cmd+c and past it in cursor with option+cmd+v

#!/bin/bash

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Convert to Single Line
# @raycast.mode silent
# @raycast.packageName Text Tools
#
# Optional parameters:
# @raycast.icon :memo:
# @raycast.shortcut cmd+opt+v
#
# Documentation:
# @raycast.description Converts clipboard text to single line and pastes it automatically
# @raycast.author Your Name
# @raycast.authorURL https://github.com/yourusername

# Get clipboard content and convert to single line
CLIPBOARD=$(pbpaste | tr '\n' ' ' | tr -s ' ')

# Copy back to clipboard
echo -n "$CLIPBOARD" | pbcopy

# Paste using AppleScript
osascript -e 'tell application "System Events" to keystroke "v" using command down'

This script:

  1. Uses tr to replace newlines with spaces
  2. Removes extra spaces with tr -s
  3. Uses AppleScript to paste

If this still doesn’t work, let’s try to debug:

  1. Have you granted Raycast accessibility permissions in System Settings?
1 Like

I applaude you for your solution, although I think cursor should just let us paste text the normal way, like it did before. There really should be flag for that.