7

I work on a remote machine through ssh. I have a very large text file there (approx. 500 lines) which I usually need to modify, then copy the contents of that file and paste it in my local browser. The way I usually do this is cat filename and then select/copy the ssh output. That takes a lot of time.

I was wondering if there is a utility that will put the remote file's contents in my local clipboard.

1

4 Answers 4

3

Try ssh pipes. Here's and example that works with OS X (Mountain Lion) (for Linux, adjust the cli clipboard program accordingly):

From the remote ssh machine, run:

$ cat /dir/file.txt | ssh user@localMachine pbcopy

You can use this functionality in remote vim editors by using ssh certificates for authorization and adding the following to vimrc on the remote machine:

vmap <C-c> y:call system("ssh user@localMachine pbcopy", getreg("\""))

Control-C in the remote editor should now copy to the local clipboard.

2

If you enable X forwarding then xclip can do this.

xclip -i -selection clipboard somefile
2

Personally, I'd open the remote file locally through e.g. Vim's SCP mode:

vim scp://uname@host/myfile

then edit and just copy it from Vim (e.g. by gg"*yG).

Alternatively you can use sshfs and the local editor of your choice.

0

Far Manager Linux port supports synchronizing clipboard between local and remote host. You just open local far2l, do "ssh somehost" inside, run remote far2l in that ssh session and get remote far2l working with your local clipboard.

It supportes Linux, *BSD and OS X; I made a special putty build to utilize this functionality from windows also.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .