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

Select and Copy from Remote Session #117

Closed
faxotherapy opened this issue Apr 10, 2019 · 3 comments
Closed

Select and Copy from Remote Session #117

faxotherapy opened this issue Apr 10, 2019 · 3 comments

Comments

@faxotherapy
Copy link

faxotherapy commented Apr 10, 2019

Hi,
thanks a lot for the plug-in. I'd like to select text and copy (transfer) it from a remote session to my local session. Although the method presented below works successfully for me I'd like to know your opinion on its last two steps; steps 3 and 4.

The first boring steps:

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

The fun part…

  1. I add tmux-yank plug-in on both my local and remote machines.
  2. I insert set -g @override_copy_command 'nc localhost 9997' in my remote tmux.conf file and reload.
@bruno-
Copy link
Member

bruno- commented Apr 11, 2019

Hey,

that looks pretty cool. I think the last 2 steps are fine.
Feel free to submit a docs PR and expand on this so others can do similar things. I propose making it a markdown file docs/copy_from_remote_session.md

@bruno- bruno- closed this as completed Apr 11, 2019
@NitroCao
Copy link

Hi @faxotherapy , I followed the 4 steps but it still did not work, can you describe the first step more detailedly?

@faxotherapy
Copy link
Author

Hello, I only have implemented the function on my MacOS platform. I haven't tried under GNU/Linux.

I created a file called local.pbcopy.9999.plist with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>local.pbcopy.9999</string>
    <key>Program</key>
    <string>/usr/bin/pbcopy</string>
    <key>StandardOutPath</key>
    <string>/tmp/pb9999.out</string>
    <key>StandardErrorPath</key>
    <string>/tmp/pb9999.err</string>
    <key>Sockets</key>
    <dict>
        <key>Listeners</key>
        <dict>
            <key>SockNodeName</key>
            <string>localhost</string>
            <key>SockServiceName</key>
            <string>9999</string>
        </dict>
    </dict>
    <key>inetdCompatibility</key>
    <dict>
        <key>Wait</key>
        <false/>
    </dict>
</dict>
</plist>

Then, I put the file in folder ~/Library/LaunchAgents so that the listener is enabled every time a user session is started. However, for the current session, I can start it immediately with:

$ cd ~/Library/LaunchAgents
$ launchctl load local.pbcopy.9999.plist
$ launchctl list | grep 9999
-       0       local.pbcopy.9999

unload to mute the listening port for the current session.

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