Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
1  
I think you got the title wrong. –  Ignacio Vazquez-Abrams Apr 5 '12 at 3:31

3 Answers 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.

share|improve this answer

If you enable X forwarding then xclip can do this.

xclip -i -selection clipboard somefile
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.