Skip to content

Instantly share code, notes, and snippets.

@kosmatov
Last active December 7, 2020 08:27
Show Gist options
  • Save kosmatov/ef29d5b200c3688bc77f5c24e9e4b80c to your computer and use it in GitHub Desktop.
Save kosmatov/ef29d5b200c3688bc77f5c24e9e4b80c to your computer and use it in GitHub Desktop.
Vim pbcopy through SSH
$ tail -3 ~/.ssh/config
Host pbcopy-host
HostName 10.0.1.1
User key
$ cat ~/.vimrc | grep pbcopy
Plug 'ahw/vim-pbcopy'
let g:vim_pbcopy_remote_cmd = "ssh pbcopy-host pbcopy"
@kosmatov
Copy link
Author

kosmatov commented Nov 20, 2020

Motivation

There is a small trick to copy any text from vim inside virtual machine running on Mac OS X host to its clipboard

vim-pbcopy

This is a Vim plugin that exposes a cy mapping in Visual mode and a cy{motion} mapping in Normal mode which both attempt to yank the selected/moved-over text and pipe it (via ssh if necessary) to the pbcopy command on a Mac OS X client. What does this mean? It means you can use cy wherever you'd normally use y and have that text available in your Mac OS X system clipboard, whether you're working locally or remotely. It also performs a simple y yank operation on your selection so you'll have it in the default " yank register as well.

ahw/vim-pbcopy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment