Paste preview
A paste can run commands the moment it arrives. On a device's command line every line break is an Enter, so a block copied by accident becomes a series of commands on whatever you are connected to. The paste preview shows such text before anything is sent, so you can read it, edit it, or cancel.
When it appears
The preview belongs to the connection that opened it. If that connection closes or reconnects while the preview is open, choose Paste again to review the text for the new connection.
| The pasted text | What happens | Setting |
|---|---|---|
| One line, with no line break | It goes straight in | none |
| Has a line break, even only a trailing one | Preview | Preview Multi-line Pastes |
| Has a control character other than tab (Escape, Ctrl+C and so on) | Preview | Preview Multi-line Pastes |
| Longer than 5,000 characters, whatever it holds | Preview | Preview Large Pastes |
Every way of pasting goes through the same check: Ctrl+Shift+V, Shift+Insert, Ctrl+V when Windows keys are on, the Edit menu, the toolbar, the right-click menu, and the browser's own paste event.
What it shows
- Where the text is going: the title names the tab, for example "Paste into core-sw1?".
- How much: the number of lines and characters, kept up to date as you edit.
- Warnings, when they apply:
- "This is a large paste." for text over 5,000 characters.
- How many control characters the text holds. They are invisible in the text and a device may act on them.
- The text itself, in a box you can edit. Line breaks are shown as lines.
Text over 256 KiB is not editable: a box holding megabytes would make the preview slow. The preview shows the first 40 and the last 10 lines instead, with long lines cut at 300 characters, and sends the text unchanged if you choose Send.
Keys
| Key | What it does |
|---|---|
| Ctrl+Enter | Send |
| Enter | A new line in the text. It does not send. |
| Esc | Cancel. Nothing is sent. |
The cursor starts in the text, not on the Send button, so a stray Enter cannot send the paste. For text too large to edit, the cursor starts on Cancel.
Settings
Both settings are in Options in the menu bar, and in the right-click menu of the terminal.
| Setting | Default | Why |
|---|---|---|
| Preview Multi-line Pastes | On | A line break runs a command. This is the common accident. |
| Preview Large Pastes | On | A wall of text is almost never meant for a command line. 5,000 characters is the mark Windows Terminal uses. |
The preview has a box, "Do not preview multi-line pastes again". Ticking it and sending switches off Preview Multi-line Pastes, and the status line says where to switch it back on. It never switches off Preview Large Pastes: that is changed in Options only, so the guard against a huge accidental paste stays until you remove it on purpose.
To restore the defaults, tick both settings in Options.
Limits
- The preview checks the text, not the device. It cannot know whether the far end is at a prompt, in an editor, or in configuration mode.
- When a program on the far end has asked for bracketed paste (most modern shells and editors do), the text arrives marked as a paste and line breaks do not run commands. Network devices generally do not ask for it, which is why the preview treats every line break as risky.
- Text is sent as fast as the connection accepts it. Over SSH a paste of any size goes through, because the host sets the pace (see Timeouts and lost connections, "Large pastes"). A slow serial console can drop characters from a long paste; paced sending for serial lines is planned.
Where it lives in the code
ui/paste.js: the rules (what counts as risky, the limits), tested byscripts/test-paste.mjs.ui/app.js,pasted()andpreviewPaste(): the preview itself.