Back to Maus

How to copy terminal output on Mac without the formatting mess

May 26, 2026 · Manuel Toledo · Ghostty, Warp, iTerm2, Terminal.app
Quick answer

Every Mac terminal copies output a little differently — trailing spaces, extra newlines, prompt prefixes that paste as > at the start of every line. The fixes are per-terminal: iTerm2 has explicit preferences, Warp has known multi-line issues, Ghostty's config is minimal, Terminal.app has no trim option. A clipboard manager with source-app tagging like Maus doesn't fix the formatting, but it stops you from losing the original when you re-copy with edits.

Why terminals copy weird

A terminal is a grid of cells. When a line of output ends before the right edge, the terminal fills the rest with spaces — because there's no "blank" cell, there are only space-cells and other-character-cells. When you drag-select multiple lines, those padding spaces get copied as real 0x20 bytes. vim is the worst offender: it writes spaces to clear the screen between buffer redraws, so even one-line files come out trailed with spaces all the way to column 80.

Then layered on top:

iTerm2 — the most configurable

iTerm2 exposes the relevant controls in Preferences → General → Selection:

For the trailing-spaces-from-vim problem, there's a long-standing iTerm2 issue (#1677) — vim paints spaces to the right margin and they end up in your copy. The workaround the maintainer suggests in issue #1793: bind a key to a Coprocess that runs pbpaste | tr -d "\n" or similar post-processing on the clipboard.

Warp — multi-line is the rough edge

Warp's block-based UX is great for reading output, but the copy/paste pipeline has documented quirks:

The practical move with Warp:

Ghostty — minimal config, minimal surprises

Ghostty's config reference exposes a basic copy_to_clipboard action and a copy_on_select behavior, but it doesn't document the same trim-trailing-whitespace controls iTerm2 has. The terminal is fast and clean, but the copy story is "what you select is what you get" — including any padding spaces or prompt prefixes you grabbed.

The pragmatic Ghostty flow:

Terminal.app — least configurable

The built-in Terminal includes trailing whitespace to the right edge of the window and has no documented option to trim it. There's no equivalent to iTerm2's "trim trailing whitespace" setting. The realistic options:

Claude Code's own copy issue

Worth knowing if you're a Claude Code user: there's an open issue (#18170) in the Claude Code repo about copying from the TUI. Copied text retains leading indentation that matches the visual padding for prompt symbols (> and ·) plus trailing whitespace. Code blocks in particular paste back unindented and need manual cleanup. The issue notes this was briefly fixed and then regressed.

Until it's fixed upstream, the workaround inside Claude Code is to copy with care (start selection after the prompt indent) or post-process the paste.

Pipe to pbcopy when you can

The terminal-quirk-free path is to skip the terminal selection entirely:

git diff | pbcopy
cat error.log | tail -50 | pbcopy
echo $PATH | pbcopy

No padding spaces, no prompt prefix, no line wrap weirdness — the bytes go straight from stdout to the pasteboard. This is the move when you know in advance you'll need to paste the output somewhere. It doesn't help when you've already run the command and are looking at the output deciding "ok, that's the part I want to paste."

Where a clipboard manager fits in

Trim settings and pbcopy handle the prevention side. The cleanup side — when you've already copied something messy and need to redo it — is where having every copy in history saves time.

With Maus:

What Maus does not do: it doesn't auto-strip trailing whitespace from your copies. The terminal-side fixes above are the right tools for that. Maus's job is to make sure you don't lose copies when you redo them, and to make the history searchable when the copy you want is two hours back.

A workflow that holds up under load

  1. iTerm2 or Ghostty as your daily terminal (better copy story than Terminal.app).
  2. Enable "Copied text includes trailing newline" → off in iTerm2 to avoid accidentally executing pasted commands.
  3. Pipe to pbcopy whenever you know the output is going to the clipboard. Cleanest path.
  4. For ad-hoc selections, a clipboard manager so you can re-copy without losing the original.
  5. For pasting into Claude or Cursor, source-app filter (iterm, warp, ghostty) makes "which terminal copy did I want" a one-keystroke filter instead of a scroll.

FAQ

Why does copying from the terminal include extra spaces?

The terminal grid fills the rest of each line with spaces. Selecting multi-line output copies those padding spaces as real characters. iTerm2 has a trim preference; Terminal.app does not. vim is especially bad because it actively writes spaces to clear the screen.

Does Ghostty handle copy formatting differently from iTerm2?

Ghostty's documented config is minimal — basic copy_to_clipboard action, copy_on_select behavior. It doesn't expose the same trim controls iTerm2 has. Selection care plus pbcopy piping is the workflow.

Why does Warp paste produce weird multi-line behavior?

Documented issues: multi-line commands touch the prompt with no spacing (#4796), clipboard sync between Warp and macOS isn't always two-way (#4247, #4314, #4811). Block-by-block copy is the cleanest path inside Warp.

How do I copy from a terminal so Claude or Cursor reads it as code?

Select carefully (skip the prompt), pipe to pbcopy when you can, and use a clipboard manager that tags clips by source app so you can find the clean one when you've made multiple copy attempts.

Is there a way to strip the prompt symbol from copied lines?

Not built into most terminals. Even Claude Code itself has an open issue (#18170) about this. The fix is post-processing or careful selection. A clipboard manager keeps every attempt available.

Stop losing copies when you redo them

Maus keeps every ⌘C from your terminal, tagged by source app. When you re-copy the same output with the prompt stripped, the messy original is still there if you need it. Free with 24h history. Pro $12.99 once for unlimited.

Download Maus for Mac For Claude Code, Cursor, Codex users