SSH client and bracketed paste mode

Thorsten Glaser
2020-10-30T21:22:06Z

Hi,

lemme correct that for you:

> Using a terminal with bracketed paste mode (see [0], [1]), I
> am not able to paste text while being in the "~C" command line
> mode.
>
> The reason for that is, that while being in that special mode,
the terminal sends the bracketed paste control characters to
OpenSSH, which does not expect it.

> I tried to figure out, which of the three involved components
> might be at fault. The component stack is:
>
> * terminal
> * local shell
> * ssh
> * remote shell

This works as follows:

? terminal sets up normal operation
? local shell starts ssh
? ssh starts remote shell on the terminal
? remote shell instructs the terminal to switch to bracketed paste mode

Now when you use an SSH escape, ssh temporarily accesses the
terminal, but bracketed paste mode is still active, which
leads to confusion.

This is also seen often in terminal multiplexers that themselves
do not implement bracketed paste mode, but one of the programs run
in them enables it. Switching to another program in the multiplexer
makes the other one suddenly get the bracketed paste escape codes.

I fear that the correct solution here is to not use bracketed paste
mode, or to disable it manually while accessing the ssh escape, or
to not paste with the mouse into the escape prompt (pasting using,
for example, GNU screen ^A], will still work).

bye,
//mirabilos (who?d analysed this in the other scenario some time ago)
--
Sometimes they [people] care too much: pretty printers [and syntax highligh-
ting, d.A.] mechanically produce pretty output that accentuates irrelevant
detail in the program, which is as sensible as putting all the prepositions
in English text in bold font.	-- Rob Pike in "Notes on Programming in
C"