Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy lines to os x clipboard from vim on remote console

Tags:

vim

macos

heroku

I'm using heroku, and I've logged gotten access to bash using heroku run bash. I found out it was possible to install vim on heroku with this shell script:

#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin

I am now wanting to take text I yank from vim on Heroku and paste it into other editors.

To be clear, this is what I am trying to fix: I yank all the text in a file to a vim buffer (using yG for instance,) but then I want to use what I've yanked by pasting it into an application like Sublime Text I'm running locally. I've also tried "*yG. That didn't work either.

I have a vague idea why this isn't working (the buffer I'm copying to is only accessible on the server,) but isn't there someway to do this besides selecting using the terminal?

like image 456
David West Avatar asked May 19 '13 20:05

David West


1 Answers

Yes, your idea is right: because Vim runs on another machine it has no access to your local clipboard or to any local command like pbcopy or pbpaste. Also, because you use Mac OS X and (I assume) iTerm.app or Terminal.app, "X forwarding" will be of no help here (you don't use X).

So, you have two options:

  • Select what you want to copy with the mouse and use your terminal emulator/system's "copy" feature.

  • Set up a complicated system where you use a remote command to scp your yanked text to your local machine where it's piped into pbcopy. I've seen things like that in the past.

But, why don't you just do your editing remotely? Or use a VCS?

like image 111
romainl Avatar answered Oct 07 '22 00:10

romainl