cyd01 / KiTTY

:computer: KiTTY, a free telnet/ssh client for Windows
https://www.9bis.com/kitty
Other
1.6k stars 137 forks source link

Support OCS52 #423

Open Kapsonfire-DE opened 2 years ago

Kapsonfire-DE commented 2 years ago

I'd really like to see support of OCS52 allowing shcopy to work https://github.com/aymanbagabas/shcopy

cyd01 commented 1 year ago

Do you try the feature send standard output to clipboard ?

mgrant0 commented 1 year ago

I have tried. I sort of got it to work using tmux.

  1. an executable script in a file named wcl:
    
    # start send to ansi printer
    echo -ne '\e[5i' >$SSH_TTY

send stdin to the outer terminal

cat >$SSH_TTY

end ansi printer output

echo -ne '\e[4i' >$SSH_TTY


2. add this to your .tmux.conf file:

bind -Tcopy-mode MouseDragEnd1Pane send -X copy-pipe-and-cancel '~/bin/wcl'


3. set the ANSI printer output to go to the clipboard in KiTTY.  

And then yes, you can select stuff on the screen and it goes to the Windows clipboard.

But it doesn't deal well with unicode.

If I use your bash function at the unix/linux bash shell without tmux, as in just log into a remote machine with KiTTY and type at the shell:

% function wcl { echo -ne '\e''[5i' cat $* echo -ne '\e''[4i' echo "Copied to Windows clipboard" 1>&2 } % echo £500 | wcl Copied to Windows clipboard

This is what I get when I paste into notepad:

£500


`€100` pastes as `€100`

I tried piping the cat to iconv to convert it to something else like utf-16 but it's even worse.  I tried several (definitely not all!) different encodings in iconv but I couldn't find one which was clean.  Any idea if this is an encoding issue?
mgrant0 commented 1 year ago

I opened an issue for this: https://github.com/cyd01/KiTTY/issues/494

mgrant0 commented 1 year ago

In regards to OSC-52 support (note the mis-spelling in the title!), yes I would also like to see that in KiTTY!

In another test I did, I managed to create a terminfo override which shoved the ESC [5i some-text ESC [4i into the terminal output but then, I get base64 encoded text in the Windows clipboard. This base64 text is what OSC-52 is doing.

It would be great if KiTTY had direct OSC-52 support. That would make getting text from tmux to Windows easier. To be clear why OSC-52 is important here is tmux has an internal copy buffer that is not connected to KiTTY's scrollback buffer. One might scroll up in tmux, copy several screenfulls to the copy-buffer and want to paste them somewhere. In KiTTY, you could try to do this manually using the scrollback buffer but this doesn't always work when sitting in pane in tmux which for me completely messes up the scrollback in KiTTY.

I'm unclear on how the reverse would be done: getting something from Windows clipboard into tmux's copy-buffer. This is a step beyond right-click pasting in KiTTY.

mgrant0 commented 1 year ago

This issue should probably be closed. OSC52 now supported in KiTTY.