Description
Description of the new feature/enhancement
For some readline experiences, they support this concept of paste bracketing.
The idea is simple:
- First, the shell emits
esc[?2004h
- This tells the terminal that this shell wants to use paste bracketing
- When paste bracketing is on, pasted text is prefixed by esc
[200~
and followed by esc[201~
by the terminal before sending the text to the shell.
Here's an example screenshot of my version of bash on macOS with readline (which doesn't support this but you can see the effect):
- first command tells the terminal to deactivate bracketed pasting
- second is a paste from the clipboard
- 3rd activates bracketed pasting
- 4th is the same paste from the clipboard but now it has \e[200~ and \e[201~ around it
Pretty much any terminal supports this... for example, here's iTerm2's doc:
https://gitlab.com/gnachman/iterm2/-/wikis/Paste-Bracketing#control-sequences
And there's a feature request in Windows Terminal: microsoft/terminal#395
and @Tyriar was considering adding this to VS Code's terminal as well.
What does supporting this mean?
This means that on macOS and Linux (and really crossplat) we can support multi-line pasting - something that has been available on Windows in conhost.exe for a very long time.
Proposed technical implementation details (optional)
At start up, PSReadLine emits \e[?2004h
to tell the terminal to use paste bracketing
When we get \e[200~
we can wait until \e[201~
before actually executing anything. (or we can wait for the ENTER
after \e[201~
)