3 ms·
Some terminal emulators / shells use some heuristics, but the most reliable way is to use a combination of a terminal emulator and shell that support bracketed
by xiaq 9y ago
Some terminal emulators / shells use some heuristics, but the most reliable way is to use a combination of a terminal emulator and shell that support bracketed paste mode. This article (https://cirw.in/blog/bracketed-paste https://cirw.in/blog/bracketed-paste) lists some terminal emulators that supports bracketed paste, and a zsh plugin that makes zsh handle bracketed paste in a safe manner.
As an alternative to zsh, Elvish (https://github.com/elves/elvish https://github.com/elves/elvish) supports bracketed paste out of the box. When you paste anything that includes a carriage return, Elvish will insert a literal return instead of executing it.
(Disclaimer: I am the author of Elvish.)