KiTTY icon indicating copy to clipboard operation
KiTTY copied to clipboard

Provide unique id for the terminal window for seamless integration with Screen manager (or similar)

Open yndx-melkov opened this issue 2 years ago • 0 comments

Kitty's reconnect feature would be incomplete unless used with a terminal window manager, such as Screen, on the remote side.

The problem is, when there are several sessions connecting to the same host, it is impossible to properly reconnect to a remote screen from the same Kitty terminal window that was used before the connection has failed. We need some ID for the Kitty terminal window, as well as a means (or syntax) to deliver that ID to the remote side.

I propose to use HWND as an ID and an escape sequence \Q that would be replaced with Hex representation of HWND in

  • Connection -> Data -> Command or
  • Connection -> SSH -> Remote Command

Example: screen -T xterm -e ^Ll -q -D -R \Q turns into screen -T xterm -e ^Ll -q -D -R 00b70c4a on the remote server.

When Kitty reconnects, each working session is restored instantly and properly.

I have a working version of the stuff, and ready to submit a pull request if these proposals are found useful. The feature in Data -> Command is a modification of SendKeyboardPlus() in kitty.c.

The second one, SSH -> Remote Command, is more complex, as it needs to send the terminal ID to the depths on ssh. I chose to add another INT value to CONFIG_OPTIONS (putty.h), write hwnd to that config value after the window is created, and read the option, doing substitution on cmd in mainchan_open_confirmation() (mainchan.c). However this variant is more comfortable for use, because the screen shell is started instantly.

yndx-melkov avatar Mar 25 '23 15:03 yndx-melkov