top | item 35226598

(no title)

gnachman | 2 years ago

iTerm2 has code to detect when the current host changes and then disables paste bracketing. An ssh session suddenly ending is a common cause of it being left on with annoying consequences.

After sending a bracketed paste, iTerm2 watches for half a second for `00~` to be echoed back and then offers to turn paste bracketing off for you.

Every modal reporting feature has similar problems: mouse reporting and focus reporting, in particular.

discuss

order

scottlamb|2 years ago

> An ssh session suddenly ending is a common cause of it being left on with annoying consequences. ... Every modal reporting feature has similar problems: mouse reporting and focus reporting, in particular.

I've hit that with mouse reporting. Now that you mention it, seems like one way to address this would be the ssh client sending the ANSI escape sequences to turn off these features on exit. I wonder if the openssh developers would be open to doing so. It also seems possible to wrap ssh in a tiny shell/whatever script that calls ssh, saves the exit status, prints these disable codes, and returns the original exit status.

scottlamb|2 years ago

...then again, as the same problem could happen with any program crashing, one could argue it should be the shell's responsibility to reset terminal state after each program invocation. It could do so blindly (always send the disable codes) or set up ptys for children + pipe program output through itself and watch for state changes that need to be reset. I wonder if any shells do this, or if any common rc scripts set post-command execution wrappers to do so.