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-paste from Remote to Local (need more precisions) #20

Open
faxotherapy opened this issue Apr 10, 2019 · 1 comment
Open

Copy-paste from Remote to Local (need more precisions) #20

faxotherapy opened this issue Apr 10, 2019 · 1 comment

Comments

@faxotherapy
Copy link

faxotherapy commented Apr 10, 2019

Hello,
thanks a lot for sharing your tmux.conf. However, I need some more precisions with regard to yank. I'd like to select text and copy it from remote session and paste it into my local session. As I prefer keeping my own tmux.conf file I only grabbed the necessary part off your conf. file. So, I have inserted in my local tmux.conf the following:

yank="~/.tmux/yank.sh"

# Copy selected text
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "$yank"
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "$yank"
bind -T copy-mode-vi Y send-keys -X copy-line \;\
    run "tmux save-buffer - | $yank"
bind-key -T copy-mode-vi D send-keys -X copy-end-of-line \;\
    run "tmux save-buffer - | $yank"
bind -T copy-mode-vi C-j send-keys -X copy-pipe-and-cancel "$yank"
bind-key -T copy-mode-vi A send-keys -X append-selection-and-cancel \;\
    run "tmux save-buffer - | $yank"

# Copy selection on drag end event, but do not cancel copy mode and do not clear selection
# clear select on subsequence mouse click
bind -T copy-mode-vi MouseDragEnd1Pane \
    send-keys -X copy-pipe "$yank"
bind -T copy-mode-vi MouseDown1Pane select-pane \;\
   send-keys -X clear-selection

I've got several questions:

  1. Do I need to copy yank.sh on remote machine as well?
  2. Do I need to insert the above extracted content to my remote tmux.conf as well?
  3. Is set -g @copy_backend_remote_tunnel_port 11988 still necessary (coming from tmux.remote.conf)? If so, do I have to copy it onto the remote machine as well?

Thanks for your time.

Notes: as a Mac user, I have:

  1. Enabled the plist file for listening on port 9999
  2. Activated remoteforward=9997 localhost:9999 (SSH)
  3. Of couse, I grabbed both files yank.sh and tmux.remote.conf, but don't know whether they must be copied on both machines or not.
  4. I must mention that I have tmux-yank plug-in installed on both machines. Just in case…

I tested the following on remote session and it works:

date | nc localhost 9997

What I'd like to do instead is selecting text on remote, press y key, and the selected content jumps into my local clipboard.

@faxotherapy faxotherapy changed the title Copy-paste from Remote to Local Copy-paste from Remote to Local (need more precisions) Apr 10, 2019
@faxotherapy
Copy link
Author

faxotherapy commented Apr 10, 2019

Just found something working nice and easy. Let's recap the first boring steps mentioned above:

  1. Setup your network listener on your local machine (MacOS, Linux). Use, for example, port 9999 as listen port.
  2. SSH to your remote machine with remoteforward=9997 localhost:9999 set in your SSH config file. If no config file, then: ssh -R 9997:localhost:9999 …@…

Now, the fun part…

  1. Play around with tmux-yank and add the plug-in on both your local and remote machines.
  2. Insert set -g @override_copy_command 'nc localhost 9997' in your remote tmux.conf file and reload.

Enjoy!

Note: also works with nested tmux sessions. No need to press F12 to turn outer session's root keybindings off.

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

1 participant