For some readline experiences, they support this concept of paste bracketing.
The idea is simple:
esc[?2004h
[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):
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: https://github.com/microsoft/terminal/issues/395
and @Tyriar was considering adding this to VS Code's terminal as well.
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.
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~
)
This would resolve this longstanding issue too: https://github.com/PowerShell/PSReadLine/issues/579.
Should it be in PowerShell consolehost too?
Oh vscode has had this support for a long time. I was just suggesting it to use as an alternative as its what most programs do instead of listening for ctrl+v, plus it may work on windows now with conpty.
For my own reference: https://cirw.in/blog/bracketed-paste