Bracketed paste is an optional feature that modifies how the terminal handles a "paste from clipboard" action by a user.
(e.g. middle mouse click in xterm, ctrl+shift+v in vte, etc)
The feature must first be enabled by sending CSI ? 2004 h to the terminal. After bracketed paste is enabled, each pasted text gets enclosed between CSI 200~ and CSI 201~.
The reason why this feature exist is well explained in the wikipedia page:

Likewise, in the Bubbline library, which we intend to use for CockroachDB's SQL shell, we also want to interpret a manually entered newline as a special "run" command, but we also want to give users the option to paste a SQL text containing newline characters without running them.
Prototype implementation
These 3 PRs:
Terminal support
| Terminal |
Bracketed Paste |
| alacritty |
✅ |
| foot |
✅ |
| kitty |
✅ |
| Konsole |
✅ |
| rxvt |
✅ |
| screen |
❌ 1 |
| st |
✅ |
| tmux |
✅ |
| vte-based |
✅ |
| wezterm |
✅ |
| xterm |
✅ |
| Linux Console |
❌ |
| Apple Terminal |
✅ |
| iTerm |
✅ |
| Windows cmd |
❌ |
| Windows Terminal |
✅ |
Bracketed paste is an optional feature that modifies how the terminal handles a "paste from clipboard" action by a user.
(e.g. middle mouse click in xterm, ctrl+shift+v in vte, etc)
The feature must first be enabled by sending
CSI ? 2004 hto the terminal. After bracketed paste is enabled, each pasted text gets enclosed betweenCSI 200~andCSI 201~.The reason why this feature exist is well explained in the wikipedia page:
Likewise, in the Bubbline library, which we intend to use for CockroachDB's SQL shell, we also want to interpret a manually entered newline as a special "run" command, but we also want to give users the option to paste a SQL text containing newline characters without running them.
Prototype implementation
These 3 PRs:
Terminal support
Footnotes
A patch is available here https://gist.github.com/saitoha/2977889 ↩