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

Copy to local OS clipboard when SSH to remote servers #242

Open
DravenJohnson opened this issue May 7, 2019 · 2 comments
Open

Copy to local OS clipboard when SSH to remote servers #242

DravenJohnson opened this issue May 7, 2019 · 2 comments

Comments

@DravenJohnson
Copy link

copy to OS clipboard (needs reattach-to-user-namespace on macOS, xsel or xclip on Linux)

Will this work when I use (*for example macOS), SSH into a remote server running Linux (*debian, ubuntu or archlinux) and use tmux with this dotfile? When I try to copy texts from remote server's tmux by using C-b Enter and v -> y, I can't get texts to my local machine.

Do i need both reattach-to-user-namespace and xsel/xclip install on both machines?

@gpakosz
Copy link
Owner

gpakosz commented May 8, 2019

Hello @DravenJohnson 👋

There are different things.

On one side there's the OS clipboard, and the other side there are tmux buffers.

Setting tmux_conf_copy_to_os_clipboard=true in your ~/.tmux.conf.local copy means that when you use bindings that normally save things into tmux buffers, they will also be copied into the OS clipboard. The data transfer is unidirectional, this configuration never reads from the OS clipboard.
This corresponds to the following sequence of actions, here with Vim bindings:

  • enter copy mode (<prefix> + Enter)
  • select some text (v then h, j, k, or l)
  • copy selection (y) ← with tmux_conf_copy_to_os_clipboard=true content goes both into tmux buffer and OS clipboard
  • after data entered OS clipboard, you paste it the usual way with e.g. CTRL+ V on Windows or Command + V on macOS

What I just described above requires xsel or xclip to be installed on Linux. For macOS, it depends: latest macOS versions don't need reattach-to-user-namespace anymore.

Now comes the SSH part. The master branch of my configuration doesn't address any data exchange between a remote and a local machine. But the work-in-progress os-clipboard branch does support this scenario:

  • SSH into a machine, where you have cloned this configuration and checked out the os-clipboard branch
  • launch tmux
  • enter copy mode (<prefix> + Enter)
  • select some text (v then h, j, k, or l)
  • copy selection (y) ← data is also copied back to the local machine through OSC 52 escape sequence

So yeah, you likely want to give the os-clipboard branch a try and report whether it works for you.

@DravenJohnson
Copy link
Author

Great, thank you so much @gpakosz. It's nice you have really details answers.

I'll try the os-clipboard and leave any feedback if there is any. Thank you.

Repository owner deleted a comment from LubosRemplik Feb 19, 2021
Repository owner deleted a comment from LubosRemplik Feb 19, 2021
Repository owner deleted a comment from LubosRemplik Feb 19, 2021
Repository owner deleted a comment from LubosRemplik Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants