Option to omit soft-wrap newlines when copying selected text #12546
Replies: 3 comments
-
Thats because in tui applications its not a softwrap (ie ghostty controlling it) in the alternate screen the application is in full control of how text is placed, choosing a new line as a behavior to combine text or not might work in alot of cases but it definitely wont work in all of them |
Beta Was this translation helpful? Give feedback.
-
|
Fair point about the alternate screen — Ghostty genuinely cannot distinguish soft-wraps from intentional newlines there since the TUI is in control of cursor positioning. Would a narrower scope work? Specifically: only strip soft-wraps in the primary screen buffer, leave the alternate screen completely untouched. That would still solve the most common case — copying long output from regular shell commands and coding agents that print to stdout (where the original WireGuard key example happened) — without doing anything unpredictable inside TUIs. The primary/alternate screen distinction is something Ghostty already tracks, so the gating could be automatic rather than a user-facing toggle. |
Beta Was this translation helpful? Give feedback.
-
|
I would prefer to copy content as every line is a newline (+ trim spaces). It's much easier to remove few newlines than to find all the places where you need to insert them. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
When copying text from Ghostty, visually wrapped terminal output can end up on the clipboard with line breaks at the terminal's visual wrap boundary. This is especially painful with coding agents and TUIs that print long shell commands, public keys, URLs, or file paths: a command that was one logical line in the terminal output may paste as multiple physical lines and become invalid or dangerous to run.
A recent real-world example was a WireGuard command containing a long public key. After copying from Ghostty output, the key was split across lines, making the command impossible to paste/run safely.
Current behavior
Ghostty has clipboard and selection options such as
copy-on-select,selection-clear-on-copy,clipboard-trim-trailing-spaces, andclipboard-codepoint-map, but I could not find a way to tell Ghostty to treat visual wrap boundaries as soft wraps during copy.Proposed behavior
Add an option or action to copy selected text while omitting newlines that exist only because of terminal soft wrapping.
Possible shapes:
clipboard-copy-soft-wraps = joinor a separate action:
The important distinction is that real newlines emitted by the application should be preserved, while soft-wrap boundaries introduced by the terminal width should be joined.
Why this might fit Ghostty
This is not asking for a generic clipboard filter hook or script runner. It is a narrow terminal-selection feature. Terminal emulators generally know whether a row is continued by soft wrap, and Ghostty/libghostty appears to track row wrap state internally, so this seems like information the copy path could use.
Use cases
AI assistance notice
This feature request was drafted with AI assistance, based on a real copy/paste failure encountered while using Ghostty with a coding agent.
Beta Was this translation helpful? Give feedback.
All reactions