Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows PowerShell remote ssh vim copy to clipboard not works #17339

Closed
soonsolidchentuo opened this issue May 31, 2024 · 12 comments
Closed

Windows PowerShell remote ssh vim copy to clipboard not works #17339

soonsolidchentuo opened this issue May 31, 2024 · 12 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@soonsolidchentuo
Copy link

Description of the new feature/enhancement

Login to Ubuntu through SSH in Powershell and edit files using Vim.

However, when I use "+y, I cannot copy the content to the Windows clipboard. Thank you.

Proposed technical implementation details (optional)

I hope it can copy content like putty. Thanks.

@soonsolidchentuo soonsolidchentuo added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label May 31, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 31, 2024
@zadjii-msft
Copy link
Member

Huh. I was pretty sure we added support for OSC 52 in #5823 (a couple years back now).

Can you capture a script trace of trying to copy in vim this way/? That should tell us how exactly they're settings the keyboard.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label May 31, 2024
@plutonium-239
Copy link

I also face the same issue using the micro editor over ssh (which supports osc52). I will try to get a trace.

@soonsolidchentuo
Copy link
Author

Sorry I can't upload the trace file. So I update to my repository. trace file

The step:

  1. I open a power shell command
  2. ssh to server-android
  3. open a file by vim
  4. try using the v + "+y (ok)
  5. exit the vim
  6. try to use the shift + ins (failed)
  7. try to use the right mouse button ( failed)

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jun 4, 2024
@zadjii-msft zadjii-msft added Issue-Bug It either shouldn't be doing this or needs an investigation. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Jun 5, 2024
@zadjii-msft
Copy link
Member

Which ssh are you using? ssh.exe that ships with Windows? ssh from a WSL distro? Or some other ssh? And which version of ssh?

Did you make sure to configure vim to actually copy to the clipboard using OSC 52 (using something like https://github.com/fcpg/vim-osc52)/?

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Jun 5, 2024
@soonsolidchentuo
Copy link
Author

I tried to add a plugin named vim-osc52
It works by the command :Oscyank

PS C:\WINDOWS\system32> ssh -V
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

I'm using the jonathonf/vim

sudo add-apt-repository ppa:jonathonf/vim 

sudo apt-get update  
sudo apt install vim 


vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 10 2022 08:40:37)
Included patches: 1-749
Modified by [email protected]
Compiled by [email protected]
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     -perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          -ruby              +wildignore
+cursorbind        -lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        +mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
-farsi             -mouse_sysmouse    -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -fdebug-prefix-map=/build/vim-WrLx0u/vim-9.0.0749=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lsodium -lrt -lacl -lattr -lgpm -ldl -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jun 6, 2024
@plutonium-239
Copy link

I'm using OpenSSH's ssh.exe

> ssh -V
OpenSSH_for_Windows_9.1p1, LibreSSL 3.6.1

Also, micro has inbuilt support for OSC52 (just a config flag clipboard: terminal which I have set).

@carlos-zamora
Copy link
Member

Hmm... Could you use debug tap and share the output /? Thanks

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Jun 12, 2024
@plutonium-239
Copy link

plutonium-239 commented Jun 12, 2024

This is the relevant output I get from debug tap on selecting and copying:

16;42;0;1;48;1_␛[16;42;0;1;48;1_␛[16;42;0;1;48;1_␛[16;42;0;1;48;1_␛[38;72;0;1;304;1_␛[?25l␛[31m␛[36;1H␣36␣␛[m␛[7m␣␛[32m␛[27m␍␊
␣37␣␛[m␛[7mmodel␣=␣Sequential(...)␛[37m␛[44m␛[27m␛[50;13H6␛[1C1)␣|␣ft:markdown␣|␣unix␣|␣utf-8␣␛[38;72;0;0;304;1_␛[16;42;0;0;32;1_␛[17;29;0;1;40;1_␛[67;46;3;1;40;1_␛[m␍␊
Cop␛[1Ced␣selection␛[67;46;3;0;40;1_␛[17;29;0;0;32;1_␛[O

The words "Copied Selection" appear in the editor's UI, so that is also included in this

image

Attempt # 2:

␛[16;42;0;1;48;1_␛[40;80;0;1;304;1_␛[?25l␛[m␛[32m␍␣32␣␛[m␛[7m␛[9CExample␣␛[31m␛[27m␍␊
␣33␣␛[37m␛[44m␛[50;13H3␛[2C)␣|␣ft:markdown␣|␣unix␣|␣utf-8␣␛[40;80;0;0;304;1_␛[40;80;0;1;304;1_␛[m␛[32m␛[33;1H␣33␣␛[m␛[7m␣␛[31m␛[27m␍␊
␣34␣␛[m␛[7m```python␛[37m␛[44m␛[27m␛[50;13H4␛[2C0)␣|␣ft:markdown␣|␣unix␣|␣utf-8␛[40;80;0;0;304;1_␛[m␛[16;42;0;0;32;1_␛[17;29;0;1;40;1_␛[67;46;3;1;40;1_␛[67;46;3;0;40;1_␛[17;29;0;0;32;1_␛[O

image

@DHowett
Copy link
Member

DHowett commented Jun 12, 2024

Thanks! It looks like OSC 52 is not making it up to the terminal emulator at all (you'd expect to see ␛]52; somewhere in there!) I would recommend checking on how to configure vim + oscyank or micro to actually send OSC 52.

@DHowett DHowett closed this as completed Jun 12, 2024
@plutonium-239
Copy link

how to configure vim + oscyank or micro to actually send OSC 52.

This is handled by setting "clipboard": "terminal" in micro's config, and this works on other terminal emulators (but I've only seen it work on a friend's machine - i.e. works on putty but does not on wt)
But your comment makes sense as well, maybe my ssh server + tmux combination is not sending OSC52s as expected.
Although, I've read that there are different forms of prefixes for control sequences, which are set in tmux terminal overrides (such as Ms=\\E]52;c;%p2%s\\7, could that be a problem?

@soonsolidchentuo
Copy link
Author

My solution is this:

  1. using "+y to copy the content.
  2. using :Osyank to copy to windows

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jun 13, 2024
@plutonium-239
Copy link

I finally found a solution! Copilot helped :)
Since I'm using tmux (v3.0a), that was not passing through the OSC52 escape sequences (as speculated above). The solution was to add a terminal override in my ~/.tmux.conf as follows:

set -as terminal-overrides ",xterm-256color:Tc:Ms=\\E]52;%p1%s;%p2%s\\007"

Note: change xterm-256color to whatever $TERM is outside of tmux, and the Tc just enables truecolor. (I figured it's good to mention here).

Now I can freely copy from micro without having to use the mouse to invoke wt's selection!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

5 participants