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

Can't make it work with Mosh #24

Open
IamGianluca opened this issue Oct 12, 2023 · 5 comments
Open

Can't make it work with Mosh #24

IamGianluca opened this issue Oct 12, 2023 · 5 comments

Comments

@IamGianluca
Copy link

Hi,

Thank you for the plugin! It sounds exactly what I was looking for 🔥

My local OS is MacOS 14. I'm using iTerm2 to connect to a remote server with mosh. The remote server is running Ubuntu 22.04 and has mosh installed. I can connect to the server, and works perfectly, but the copy to local clipboard and paste from local clipboard functionality doesn't work. Is mosh supported?

If using ssh instead of mosh, things work, even without this plugin. I wanted to use this plugin hoping it would make the copy/paste from/to local clipboard work.

@ojroques
Copy link
Owner

ojroques commented Oct 12, 2023

This sounds like mosh does not support OSC52 indeed. This issue may be related: mobile-shell/mosh#637. Try using this PR maybe: mobile-shell/mosh#1054

@kmac
Copy link
Contributor

kmac commented Oct 12, 2023

As another data point: I am using mosh and it works for the scope of this plugin.

mosh --version
mosh 1.4.0 [build mosh-1.4.0-dirty]

Working with both Windows Terminal (client) and linux clients. The backend is linux. I did have to force my server-side to the most recent mosh version to get it working.

Note: I'm also using tmux on the far end but I don't think that's related. I'm also using the tmux_passthrough setting which just merged (thanks ojroques). I can't see how that would be related to mosh though.

There is an edge case with tmux and the copy-pipe command that I can't get to work (while copy-pipe-and-cancel does), but that's not within nvim.

@kmac
Copy link
Contributor

kmac commented Oct 12, 2023

@IamGianluca I found the 'yank' script from https://sunaku.github.io/tmux-yank-osc52.html to be helpful when testing out osc52 on the remote. You can use it without tmux. It's a simple script to yank text via osc52. You could try it outside of nvim to make sure that you've got basic functionality working over mosh before moving into testing this plugin inside nvim.

@IamGianluca
Copy link
Author

IamGianluca commented Oct 12, 2023

Upgrading mosh to 1.4.0 on both client and server, upgrading tmux to 3.3a, plus the changes below on tmux.conf fixed the issue for me.

set -s set-clipboard on
set-option -ag terminal-overrides ",xterm-256color:Ms=\\E]52;c;%p2%s\\7"

I can't describe the joy of copying the above from my remote config file with yy and pasting it on my local browser with Cmd+v 😄

FYI, it works even without using this plugin.

EDIT: I've also set vim.opt.clipboard = "unnamedplus" in the neovim config.

@kmac
Copy link
Contributor

kmac commented Oct 13, 2023

@IamGianluca I may have to revisit using unamedplus in my config... thanks - it seems like it will be more convenient.

Btw, I think the recent commit for 'tmux_passthrough' support should get rid of the need for that terminal overrides option. It uses a control code to tell tmux to pass the next command through to the terminal.

I'd be curious if the following changes work for you:

Remove your terminal-overrides, but set 'allow-passthrough on'

# set -s set-clipboard on  # (is no longer required - default 'external' is sufficient)
allow-passthrough on

Then set 'tmux_passthrough = true' in your plugin settings:

require('osc52').setup {
  tmux_passthrough = true, 
}

Or not, if you don't want to bother :-) I'm mainly curious, since I found the allow-passthrough in tmux seemed to solve a lot of my problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants