Skip to content

Instantly share code, notes, and snippets.

@andyshinn
Created June 9, 2016 15:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save andyshinn/dd6cabc38194e57d4014d291a03a1995 to your computer and use it in GitHub Desktop.
Save andyshinn/dd6cabc38194e57d4014d291a03a1995 to your computer and use it in GitHub Desktop.
pbcopy over SSH

Install

  • Add pbcopy.plist to your ~/Library/LaunchAgents/ folder.
  • Launch the listener with launchctl load ~/Library/LaunchAgents/pbcopy.plist.
  • Add RemoteForward 2224 127.0.0.1:2224 in your ~/.ssh/config file under your Host * or specific hosts sections.
  • Add [ -n "$SSH_CLIENT" ] && alias pbcopy="nc localhost 2224" to your remote ~/.bash_profile or other shell profile.
  • Enjoy pbcopy remotely!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>localhost.pbcopy</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/pbcopy</string>
</array>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>2224</string>
<key>SockNodeName</key>
<string>127.0.0.1</string>
</dict>
</dict>
</dict>
</plist>
@dilawar
Copy link

dilawar commented Aug 5, 2018

Thanks. This worked on my ssh session to OSX. I've been searching for a solution for a very long time. https://apple.stackexchange.com/questions/267366/cfpasteboardref-cfpasteboardcreatecfallocatorref-cfstringref-failed-to-cre

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