Skip to content

Instantly share code, notes, and snippets.

@Jayphen
Created February 6, 2015 01:26
Show Gist options
  • Save Jayphen/0a60c16c7e67118446aa to your computer and use it in GitHub Desktop.
Save Jayphen/0a60c16c7e67118446aa to your computer and use it in GitHub Desktop.
Pbcopy from remote SSH session back to OSX

Enable reverse tunelling on port 2224 locally…

echo "RemoteForward 2224 localhost:2224" >> ~/.ssh/config

SSH in to your server (I've only tried this on an Amazon AMI) and cat something

cat large-file.txt | nc localhost 2224

Gape in awe as the contents of large-file.txt are copied to the clipboard of your Mac. You may want to alias nc localhost 2224 to pbcopy.

###Bonus tip for Vim users

Add this to your .vimrc

" Maps pbcopy in command mode to copy back out to Mac session
cmap pbcopy !nc localhost 2224<CR>u

Select some text, switch to command mode and type pbcopy and voila!

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